Ë
    (täihæ  ã                   ó:  — d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlmZmZ d dlmZ d dlmZmZmZmZ d dlZ d dl!Z"d dl#Z"d dl$Z$d dl%m&Z& d dl'm(Z( d	d
l)m*Z* d	dl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> d	dlm?Z?  e:«       rKd dl@Z@e@jP                  j‚                  duZBe@jP                  j†                  duZD eEe@jP                  dd«      duZFndZBdZDdZF e	jŽ                  «       ZH e?eI«      ZJeJj—                  d«        e8«       xrX  e(j˜                   e(j˜                  ejš                  jQ                  d«      «      jœ                  «       e(j˜                  d«      kD  ZO e>«       xrX  e(j˜                   e(j˜                  ejš                  jQ                  d«      «      jœ                  «       e(j˜                  d«      kD  ZPeOxr ePZQ eR ej¦                  dd«      «      ZT e:«       �rCd dl@Z@dejª                  v r"ejª                  d   ZV	  ej®                  eV«      ZXdejª                  v r7ejª                  d   Z[	  e@j¸                  e[«      ZXeJj½                  de[› �«       nÄe@j†                  j¿                  «       rdZ[ne@jÀ                  j¿                  «       rdZ[ndZ[ e(j˜                   e(j˜                  e@jÂ                  «      jœ                  «       e(j˜                  d«      k\  Zbebr= ece@jÈ                  d«      Zeeer&e@jÈ                  jÌ                  j¿                  «       rdne[Z[d	d lgmhZh d!„ Zid"„ Zjd#„ Zk	 	 	 	 dªd$„Zld«d%„Zmd&eRfd'„Znd¬d(„Zo eod)d¬*«      Zp eod+d¬*«      Zq eod,d¬*«      Zrd­d-„Zsd.„ Ztd/„ Zud0„ Zvd1„ Zwd2„ Zxd3„ Zyd4„ Zzd5„ Z{d6„ Z|d7„ Z}d8„ Z~d9„ Zd:„ Z€d;„ Z�d<„ Z‚d=„ Zƒd>„ Z„d?„ Z…d@„ Z†dA„ Z‡dB„ ZˆdC„ Z‰dD„ ZŠdE„ Z‹dF„ ZŒdG„ Z�dH„ ZŽdI„ Z�dJ„ Z�dK„ Z‘dL„ Z’dM„ Z“dN„ Z”dO„ Z•dP„ Z–dQ„ Z—dR„ Z˜dS„ Z™dT„ ZšdU„ Z›d«dVeœe �j:                  z  dWeœdz  d&e �j:                  fdX„Zžd®dZeœd[eœdz  d\eŸdz  fd]„Z d^eœe"�jB                  �jB                  z  d&e"�jB                  �jB                  fd_„Z¢d^e"�jB                  d`eRfda„Z£d«d^e¤e"�jB                  �jB                     dbeœd&eœfdc„Z¥edd„ «       Z¦d«deeœfdf„Z§d«dgeœfdh„Z¨d«die¤e �j:                     djeœd&eœfdk„Z©d&e �j:                  fdl„Zªi Z«dm„ Z¬dn„ Z­d¯doeRdpe®dz  dqeœdz  fdr„Z¯d°ds„Z° G dt„ du«      Z±dv„ Z²dw„ Z³dx„ Z´dy„ Zµ e:«       �rœdYdYdYddYdzœZ¶e@j†                  �jn                  e@jÀ                  �jn                  de@jÌ                  �jn                  ddzœZ¸e@j†                  �jr                  e@jÀ                  �jr                  d{„ d|„ d dzœZºe@j†                  �jv                  e@jÀ                  �jv                  e@�jv                  e@jÌ                  �jv                  e@�jv                  dzœZ¼e@j†                  �jz                   eEe@jÀ                  d}d«      ddddzœZ¾e@j†                  �j~                   eEe@jÀ                  d}d«      ddddzœZÀe@j†                  �j‚                   eEe@jÀ                  d~d«      d d d dzœZÂe@j†                  �j†                   eEe@jÀ                  dd«      ddddzœZÄd€eœd�eÅeœef   fd‚„ZÆd€eœdƒeRfd„„ZÇd€eœfd…„ZÈd€eœfd†„ZÉd€eœfd‡„ZÊd€eœfdˆ„ZËd€eœfd‰„ZÌd€eœfdŠ„ZÍd€eœfd‹„ZÎ e:«       rìdŒeÅeœef   d�eœfdŽ„ZÏd�ejª                  v rÑejª                  d�   ZÐ eeÐ«      �j£                  «       s eÒd�eÐ› �«      ‚	 eÐdeÐ�j§                  d‘«       ZÔ ej®                  eÔ«      ZÕ	 eÕ�j¬                  Z×dejª                  v re[e×k7  rd”e[› d•e×› d–�ZÙeÙd—z  ZÙ eÒeÙ«      ‚e×Z[ eÏe¼d˜«        eÏe¸d™«        eÏeºdš«        eÏe¶d›«        eÏe¾dœ«        eÏeÀd�«        eÏeÂdž«       eÚeœdz  eRdz  f   ZÛe �j¸                  d&eÛfdŸ„«       ZÝereeÛef   ZÞneZÞ e:«       rid d lßmàZà d d¡lámâZâmãZãmäZämåZåmæZæ 	 d«d¢e@�jÎ                  �jÐ                  d£eœd¤eœd¥eRdz  d&eeœ   f
d¦„Zé	 d«d¢e@�jÎ                  �jÐ                  d£eœd¤eœd¥eRdz  d&eŸf
d§„Zê G d¨„ d©eÞ«      Zëy# eY$ rZZ eYdeV› deZ› �«      eZ‚dZZ[Zww xY w# e]$ rZZ e]de[› �«      eZ‚dZZ[Zww xY w# eÒ$ rZZ eÒd’eÐ› �«      eZ‚dZZ[Zww xY w# eØ$ r	  eØd“«      ‚w xY w)±é    N)ÚUserDict)Úcontextmanager)ÚBytesIOÚStringIO)ÚPath)ÚTYPE_CHECKINGÚAnyÚCallableÚSet)Únorm)Úversioné   )ÚDIFFUSERS_REQUEST_TIMEOUT)ÚBACKENDS_MAPPINGÚis_accelerate_availableÚis_bitsandbytes_availableÚis_compel_availableÚis_flax_availableÚis_gguf_availableÚis_kernels_availableÚis_note_seq_availableÚis_nvidia_modelopt_availableÚis_onnx_availableÚis_opencv_availableÚis_optimum_quanto_availableÚis_peft_availableÚis_timm_availableÚis_torch_availableÚis_torch_versionÚis_torchao_availableÚis_torchsde_availableÚis_transformers_available)Ú
get_loggerÚxpuFz±diffusers.utils.testing_utils' is deprecated and will be removed in a future version. Determinism and device backend utilities have been moved to `diffusers.utils.torch_utils`. Úpeftz0.5Útransformersz4.33ÚBIG_GPU_MEMORYé(   ÚDIFFUSERS_TEST_BACKENDz+Failed to import `DIFFUSERS_TEST_BACKEND` 'zg'! This should be the name of an installed module                     to enable a specified backend.):
ÚDIFFUSERS_TEST_DEVICEzRUnknown testing device specified by environment variable `DIFFUSERS_TEST_DEVICE`: ztorch_device overrode to ÚcudaÚcpuz1.12Úmps)Ú get_torch_cuda_device_capabilityc                 óÞ   — t        «       st        d«      ‚t        j                  | |g|¢­i |¤Žs>J d| |z
  j	                  «       j                  «       › d| |z
  j	                  «       › d�«       ‚y)Nz3PyTorch needs to be installed to use this function.zMax diff is absolute z. Diff tensor is Ú.T)r   Ú
ValueErrorÚtorchÚallcloseÚabsÚmax)ÚaÚbÚargsÚkwargss       úl/Volumes/fast/ai/experiments/MLX_z-image/.venv/lib/python3.12/site-packages/diffusers/utils/testing_utils.pyÚtorch_all_closer;      sp   € ÜÔÜÐNÓOÐOÜ�>‰>˜!˜QÐ0 Ò0¨Ò0ØdÐ-¨q°1©u¯k©k«m×.?Ñ.?Ó.AÐ-BÐBSÐUVÐYZÑUZ×T_ÑT_ÓTaÐSbÐbcÐdÓdˆuØó    c                 óˆ   — t        j                  | |«      t        | «      t        |«      z  z  }d|j                  «       z
  }|S )Nç      ð?)ÚnpÚdotr   Úmean)r6   r7   Ú
similarityÚdistances       r:   Ú numpy_cosine_similarity_distancerD   ‡   s9   € Ü—‘˜˜1“¤ a£¬4°«7Ñ!2Ñ3€JØ�Z—_‘_Ó&Ñ&€Hà€Or<   c                 ón  — | j                  «       |j                  «       }} | j                  «       D ]$  \  }}t        |t        «      sŒt	        |«      | |<   Œ& |j                  «       D ]$  \  }}t        |t        «      sŒt	        |«      ||<   Œ& | D ]  }||vr y| |   ||   k7  sŒ y |D ]  }|| vsŒ y y)NFT)ÚcopyÚitemsÚ
isinstanceÚsetÚsorted)Údict1Údict2ÚkeyÚvalues       r:   Úcheck_if_dicts_are_equalrO   Ž   sµ   € Ø—:‘:“< §¡£ˆ5€Eà—k‘k–m‰
ˆˆUÜ�eœSÕ!Ü ›ˆE�#ŠJð $ð —k‘k–m‰
ˆˆUÜ�eœSÕ!Ü ›ˆE�#ŠJð $ó ˆØ�eÑÙØ�‰:˜˜s™Ó#Ùð	 ó ˆØ�eÒÙð ð r<   c           	      ó¤  — |rt        j                  d¬«       t        j                  j	                  d«      }t        j
                  | «      st        j                  | «      } |r| ddd …dd …df   } t        | j                  «       j                  «       j                  «       j                  t         j                  «      «      j                  dd«      }|j                  d	|› d
�«      }|j                  d«      \  }}	}
|
j                  «       d   }
t        |d«      5 }t!        dj#                  ||	|
|g«      |¬«       d d d «       y # 1 sw Y   y xY w)Ni'  )Ú	thresholdÚPYTEST_CURRENT_TESTr   éýÿÿÿéÿÿÿÿÚ
Ú Útensorz = np.arrayz::r6   ©Úfile)r2   Úset_printoptionsÚosÚenvironÚgetÚ	is_tensorÚ
from_numpyÚstrÚdetachr,   ÚflattenÚtoÚfloat32ÚreplaceÚsplitÚopenÚprintÚjoin)rW   Úlimit_to_slicesÚmax_torch_printÚfilenameÚexpected_tensor_nameÚ	test_nameÚ
tensor_strÚ
output_strÚ	test_fileÚ
test_classÚtest_fnÚfs               r:   Úprint_tensor_testru   ¥   s  € ñ Ü×Ñ¨Õ0ä—
‘
—‘Ð4Ó5€IÜ�?‰?˜6Ô"Ü×!Ñ! &Ó)ˆÙØ˜˜2™3 ¡ R˜Ñ(ˆä�V—]‘]“_×(Ñ(Ó*×2Ñ2Ó4×7Ñ7¼¿¹ÓFÓG×OÑOÐPTÐVXÓY€Jð ×#Ñ# HÐ1EÐ0FÀkÐ.RÓS€JØ%.§_¡_°TÓ%:Ñ"€Iˆz˜7Ø�m‰m‹o˜aÑ €GÜ	ˆh˜Ô	 Üˆd�i‰i˜ J°¸ÐDÓEÈAÕN÷ 
×	Ñ	ús   Ä!EÅEc                 ón  — t        j                  «       d   d   }t        j                  j	                  t        j                  j                  |«      «      }|j                  d«      s1t        j                  j                  |«      }|j                  d«      sŒ1| rt        || «      j                  «       S |S )a  
    Args:
        append_path: optional path to append to the tests dir path
    Return:
        The full path to the `tests` dir, so that the tests can be invoked from anywhere. Optionally `append_path` is
        joined after the `tests` dir the former is provided.
    r   Útests)	ÚinspectÚstackr[   ÚpathÚabspathÚdirnameÚendswithr   Úas_posix)Úappend_pathÚcaller__file__Ú	tests_dirs      r:   Úget_tests_dirr‚   ¿   s‰   € ô —]‘]“_ QÑ'¨Ñ*€NÜ—‘—‘¤§¡§¡°Ó ?Ó@€Ià× Ñ  Ô)Ü—G‘G—O‘O IÓ.ˆ	ð × Ñ  Õ)ñ Ü�I˜{Ó+×4Ñ4Ó6Ð6àÐr<   Úreturnc                 óR   — | j                  «       } | dv ry| dv ryt        d| › �«      ‚)zÆ
    Converts a string representation of truth to `True` (1) or `False` (0). True values are `y`, `yes`, `t`, `true`,
    `on`, and `1`; False value are `n`, `no`, `f`, `false`, `off`, and `0`;
    )ÚyÚyesÚtÚtrueÚonÚ1r   )ÚnÚnort   ÚfalseÚoffÚ0r   zinvalid truth value )Úlowerr1   )rN   s    r:   Ústr_to_boolr‘   Ö   s:   € ð
 �K‰K‹M€EØÐ4Ñ4ØØ	Ð7Ñ	7ØäÐ/°¨wÐ7Ó8Ð8r<   c                 ó¢   — 	 t         j                  |    }	 t        |«      }|S # t        $ r t        d| › d�«      ‚w xY w# t        $ r |}Y |S w xY w)NzIf set, z must be yes or no.)r[   r\   r‘   r1   ÚKeyError)rM   ÚdefaultrN   Ú_values       r:   Úparse_flag_from_envr–   ä   sp   € ðBÜ—
‘
˜3‘ˆð	BÜ  Ó'ˆFð €Møô ò 	Bä˜x¨ uÐ,?Ð@ÓAÐAð	Bûô ò à‰ð €Mðús   ‚? –# £<¿AÁAÚRUN_SLOW)r”   ÚRUN_NIGHTLYÚRUN_COMPILEc                 ó  — |€t         }d}| D ]  }||z  }Œ	 g }t        |«      D ]$  }|j                  |j                  «       |z  «       Œ& t	        j
                  |t        j                  ¬«      j                  | «      j                  «       S )zCreates a random float32 tensorr   )ÚdataÚdtype)	Ú
global_rngÚrangeÚappendÚrandomr2   rW   ÚfloatÚviewÚ
contiguous)ÚshapeÚscaleÚrngÚnameÚ
total_dimsÚdimÚvaluesÚ_s           r:   Úfloats_tensorr¬   ù   s}   € à
€{Üˆà€JÛˆØ�cÑ‰
ð ð €FÜ�:ÖˆØ�‰�c—j‘j“l UÑ*Õ+ð ô �<‰<˜V¬5¯;©;Ô7×<Ñ<¸UÓC×NÑNÓPÐPr<   c                 óB   —  t        j                  t        d«      | «      S )z™
    Decorator marking a test as slow.

    Slow tests are skipped by default. Set the RUN_SLOW environment variable to a truthy value to run them.

    ztest is slow)ÚunittestÚ
skipUnlessÚ_run_slow_tests©Ú	test_cases    r:   Úslowr³   	  s   € ð @Œ8×Ñœ°Ó?À	ÓJÐJr<   c                 óB   —  t        j                  t        d«      | «      S )zº
    Decorator marking a test that runs nightly in the diffusers CI.

    Slow tests are skipped by default. Set the RUN_NIGHTLY environment variable to a truthy value to run them.

    ztest is nightly)r®   r¯   Ú_run_nightly_testsr±   s    r:   Únightlyr¶     s!   € ð FŒ8×ÑÔ1Ð3DÓEÀiÓPÐPr<   c                 óB   —  t        j                  t        d«      | «      S )zÃ
    Decorator marking a test that runs compile tests in the diffusers CI.

    Compile tests are skipped by default. Set the RUN_COMPILE environment variable to a truthy value to run them.

    ztest is torch compile)r®   r¯   Ú_run_compile_testsr±   s    r:   Úis_torch_compiler¹     s!   € ð LŒ8×ÑÔ1Ð3JÓKÈIÓVÐVr<   c                 óJ   —  t        j                  t        «       d«      | «      S )zo
    Decorator marking a test that requires PyTorch. These tests are skipped when PyTorch isn't installed.
    útest requires PyTorch)r®   r¯   r   r±   s    r:   Úrequire_torchr¼   '  s$   € ð NŒ8×ÑÔ1Ó3Ð5LÓMÈiÓXÐXr<   c                 óf   —  t        j                  t        «       xr t        dd«      d«      | «      S )zl
    Decorator marking a test that requires PyTorch 2. These tests are skipped when it isn't installed.
    ú>=z2.0.0ztest requires PyTorch 2)r®   r¯   r   r   r±   s    r:   Úrequire_torch_2r¿   .  s6   € ð tŒ8×ÑÔ1Ó3ÒWÔ8HÈÈwÓ8WÐYrÓsØóð r<   c                 ó   ‡ — ˆ fd„}|S )zPDecorator marking a test that requires torch with a specific version or greater.c                 ór   •— t        «       xr t        d‰«      } t        j                  |d‰› �«      | «      S )Nr¾   z>test requires torch with the version greater than or equal to ©r   r   r®   r¯   ©r²   Úcorrect_torch_versionÚtorch_versions     €r:   Ú	decoratorz6require_torch_version_greater_equal.<locals>.decorator:  sH   ø€ Ü 2Ó 4Ò ^Ô9IÈ$ÐP]Ó9^Ðð
Œx×"Ñ"Ø!Ð%cÐdqÐcrÐ#só
à
óð 	r<   © ©rÅ   rÆ   s   ` r:   Ú#require_torch_version_greater_equalrÉ   7  ó   ø€ ôð Ðr<   c                 ó   ‡ — ˆ fd„}|S )zMDecorator marking a test that requires torch with a specific version greater.c                 ór   •— t        «       xr t        d‰«      } t        j                  |d‰› �«      | «      S )NÚ>z2test requires torch with the version greater than rÂ   rÃ   s     €r:   rÆ   z0require_torch_version_greater.<locals>.decoratorF  sG   ø€ Ü 2Ó 4Ò ]Ô9IÈ#È}Ó9]Ðð
Œx×"Ñ"Ø!Ð%WÐXeÐWfÐ#gó
à
óð 	r<   rÇ   rÈ   s   ` r:   Úrequire_torch_version_greaterrÎ   C  rÊ   r<   c                 ó`   —  t        j                  t        «       xr	 t        dk(  d«      | «      S )z8Decorator marking a test that requires CUDA and PyTorch.r+   ztest requires PyTorch+CUDA©r®   r¯   r   Útorch_devicer±   s    r:   Úrequire_torch_gpurÒ   O  s0   € àmŒ8×ÑÔ1Ó3ÒN¼ÈÑ8NÐPlÓmØóð r<   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó¬   •— t         j                  j                  «       r5t        «       }t	        j
                  t        |«      t        ‰«      k(  d«      S y )Nz/Test not supported for this compute capability.)r2   r+   Úis_availabler.   r®   r¯   r¡   )r²   Úcurrent_compute_capabilityÚexpected_compute_capabilitys     €r:   rÆ   z3require_torch_cuda_compatibility.<locals>.decoratorW  sK   ø€ Ü�:‰:×"Ñ"Ô$Ü)IÓ)KÐ&Ü×&Ñ&ÜÐ0Ó1´UÐ;VÓ5WÑWØAóð ð %r<   rÇ   )r×   rÆ   s   ` r:   Ú require_torch_cuda_compatibilityrØ   V  s   ø€ ôð Ðr<   c                 ó`   —  t        j                  t        «       xr	 t        dk7  d«      | «      S )zJDecorator marking a test that requires an accelerator backend and PyTorch.r,   z!test requires accelerator+PyTorchrÐ   r±   s    r:   Úrequire_torch_acceleratorrÚ   c  s0   € àsŒ8×ÑÔ1Ó3ÒM¼ÈÑ8MÐOrÓsØóð r<   c                 óÂ   — t        «       s t        j                  d«      | «      S ddl} t        j                  |j
                  j                  «       dkD  d«      | «      S )a  
    Decorator marking a test that requires a multi-GPU setup (in PyTorch). These tests are skipped on a machine without
    multiple GPUs. To run *only* the multi_gpu tests, assuming all test names contain multi_gpu: $ pytest -sv ./tests
    -k "multi_gpu"
    r»   r   Nr   ztest requires multiple GPUs)r   r®   Úskipr2   r¯   r+   Údevice_count©r²   r2   s     r:   Úrequire_torch_multi_gpurß   j  sR   € ô ÔØ5Œx�}‰}Ð4Ó5°iÓ@Ð@ãà\Œ8×Ñ˜uŸz™z×6Ñ6Ó8¸1Ñ<Ð>[Ó\Ð]fÓgÐgr<   c                 ó   — t        «       s t        j                  d«      | «      S ddl} t        j                  |j
                  j                  «       dkD  xs |j                  j                  «       dkD  d«      | «      S )z©
    Decorator marking a test that requires a multi-accelerator setup (in PyTorch). These tests are skipped on a machine
    without multiple hardware accelerators.
    r»   r   Nr   z,test requires multiple hardware accelerators)r   r®   rÜ   r2   r¯   r+   rÝ   r$   rÞ   s     r:   Úrequire_torch_multi_acceleratorrá   x  sr   € ô
 ÔØ5Œx�}‰}Ð4Ó5°iÓ@Ð@ãðŒ8×ÑØ�
‰
×ÑÓ! AÑ%ÒE¨¯©×)?Ñ)?Ó)AÀAÑ)EÐGuóàóð r<   c                 óT   —  t        j                  t        t        «      d«      | «      S )zZDecorator marking a test that requires an accelerator with support for the FP16 data type.z+test requires accelerator with fp16 support)r®   r¯   Ú_is_torch_fp16_availablerÑ   r±   s    r:   Ú#require_torch_accelerator_with_fp16rä   ‡  ó(   € àuŒ8×ÑÔ7¼ÓEÐGtÓuØóð r<   c                 óT   —  t        j                  t        t        «      d«      | «      S )zZDecorator marking a test that requires an accelerator with support for the FP64 data type.z+test requires accelerator with fp64 support)r®   r¯   Ú_is_torch_fp64_availablerÑ   r±   s    r:   Ú#require_torch_accelerator_with_fp64rè   Ž  rå   r<   c                 óh  — t        «       s t        j                  d«      | «      S ddl}|j                  j                  «       s t        j                  d«      | «      S |j                  j                  d«      }|j                  dz  } t        j                  |t        k\  dt        › d�«      | «      S )z„
    Decorator marking a test that requires a bigger GPU (24GB) for execution. Some example pipelines: Flux, SD3, Cog,
    etc.
    r»   r   Nútest requires PyTorch CUDAé   @z"test requires a GPU with at least ú
 GB memory)
r   r®   rÜ   r2   r+   rÕ   Úget_device_propertiesÚtotal_memoryr¯   r'   )r²   r2   Údevice_propertiesrî   s       r:   Úrequire_big_gpu_with_torch_cudarð   •  s¥   € ô
 ÔØ5Œx�}‰}Ð4Ó5°iÓ@Ð@ãà�:‰:×"Ñ"Ô$Ø:Œx�}‰}Ð9Ó:¸9ÓEÐEàŸ
™
×8Ñ8¸Ó;ÐØ$×1Ñ1°WÑ=€LðŒ8×ÑØœÑ&Ð*LÌ^ÐL\Ð\fÐ(góàóð r<   c                 óF  — ddl }|j                  j                  | «      } t        «       s t	        j
                  d«      | «      S ddl}|j                  j                  «       s5|j                  j                  «       s t	        j
                  d«      | «      S |j                  j                  «       r|j                  j                  d«      }n|j                  j                  d«      }|j                  dz  } t	        j                  |t        k\  dt        › d�«      | «      S )z•
    Decorator marking a test that requires a bigger hardware accelerator (24GB) for execution. Some example pipelines:
    Flux, SD3, Cog, etc.
    r   Nr»   rê   rë   z3test requires a hardware accelerator with at least rì   )ÚpytestÚmarkÚbig_acceleratorr   r®   rÜ   r2   r+   rÕ   r$   rí   rî   r¯   r'   )r²   rò   r2   rï   rî   s        r:   Úrequire_big_acceleratorrõ   ©  sñ   € ó
 à—‘×+Ñ+¨IÓ6€IäÔØ5Œx�}‰}Ð4Ó5°iÓ@Ð@ãà�J‰J×#Ñ#Ô%¨¯©×)?Ñ)?Ô)AØ:Œx�}‰}Ð9Ó:¸9ÓEÐEà‡y�y×ÑÔØ!ŸI™I×;Ñ;¸AÓ>Ñà!ŸJ™J×<Ñ<¸QÓ?Ðà$×1Ñ1°WÑ=€LðŒ8×ÑØœÑ&Ø
=¼nÐ=MÈZÐXóð óð r<   c                 ól   —  t        j                  t        «       xr t        t        «      d«      | «      S )zPDecorator marking a test that requires an accelerator with support for training.z/test requires accelerator with training support)r®   r¯   r   Úbackend_supports_trainingrÑ   r±   s    r:   Ú'require_torch_accelerator_with_trainingrø   Æ  s7   € ðŒ8×ÑÜÓÒHÔ!:¼<Ó!HØ9óð óð r<   c                 óH   —  t        j                  t        dk7  d«      | «      S )z9Decorator marking a test to skip if torch_device is 'mps'r-   ztest requires non 'mps' device©r®   r¯   rÑ   r±   s    r:   Úskip_mpsrû   Î  s#   € àWŒ8×Ñœ|¨uÑ4Ð6VÓWÐXaÓbÐbr<   c                 óJ   —  t        j                  t        «       d«      | «      S )zv
    Decorator marking a test that requires JAX & Flax. These tests are skipped when one / both are not installed
    ztest requires JAX & Flax)r®   r¯   r   r±   s    r:   Úrequire_flaxrý   Ó  s%   € ð PŒ8×ÑÔ0Ó2Ð4NÓOÐPYÓZÐZr<   c                 óJ   —  t        j                  t        «       d«      | «      S )z�
    Decorator marking a test that requires compel: https://github.com/damian0815/compel. These tests are skipped when
    the library is not installed.
    ztest requires compel)r®   r¯   r   r±   s    r:   Úrequire_compelrÿ   Ú  s$   € ð
 NŒ8×ÑÔ2Ó4Ð6LÓMÈiÓXÐXr<   c                 óJ   —  t        j                  t        «       d«      | «      S )zw
    Decorator marking a test that requires onnxruntime. These tests are skipped when onnxruntime isn't installed.
    ztest requires onnxruntime)r®   r¯   r   r±   s    r:   Úrequire_onnxruntimer  â  s%   € ð QŒ8×ÑÔ0Ó2Ð4OÓPÐQZÓ[Ð[r<   c                 óJ   —  t        j                  t        «       d«      | «      S )zq
    Decorator marking a test that requires note_seq. These tests are skipped when note_seq isn't installed.
    ztest requires note_seq)r®   r¯   r   r±   s    r:   Úrequire_note_seqr  é  ó%   € ð RŒ8×ÑÔ4Ó6Ð8PÓQÐR[Ó\Ð\r<   c                 óH   —  t        j                  t        dk7  d«      | «      S )zž
    Decorator marking a test that requires a hardware accelerator backend. These tests are skipped when there are no
    hardware accelerator available.
    r,   z$test requires a hardware acceleratorrú   r±   s    r:   Úrequire_acceleratorr  ð  s&   € ð
 ^Œ8×Ñœ|¨uÑ4Ð6\Ó]Ð^gÓhÐhr<   c                 óJ   —  t        j                  t        «       d«      | «      S )zq
    Decorator marking a test that requires torchsde. These tests are skipped when torchsde isn't installed.
    ztest requires torchsde)r®   r¯   r!   r±   s    r:   Úrequire_torchsder  ø  r  r<   c                 óB   —  t        j                  t        d«      | «      S )z†
    Decorator marking a test that requires PEFT backend, this would require some specific versions of PEFT and
    transformers.
    ztest requires PEFT backend©r®   r¯   ÚUSE_PEFT_BACKENDr±   s    r:   Úrequire_peft_backendr  ÿ  s!   € ð
 OŒ8×ÑÔ/Ð1MÓNÈyÓYÐYr<   c                 óJ   —  t        j                  t        «       d«      | «      S )zi
    Decorator marking a test that requires timm. These tests are skipped when timm isn't installed.
    ztest requires timm)r®   r¯   r   r±   s    r:   Úrequire_timmr    s$   € ð JŒ8×ÑÔ0Ó2Ð4HÓIÈ)ÓTÐTr<   c                 óJ   —  t        j                  t        «       d«      | «      S )zy
    Decorator marking a test that requires bitsandbytes. These tests are skipped when bitsandbytes isn't installed.
    ztest requires bitsandbytes)r®   r¯   r   r±   s    r:   Úrequire_bitsandbytesr    s%   € ð ZŒ8×ÑÔ8Ó:Ð<XÓYÐZcÓdÐdr<   c                 óJ   —  t        j                  t        «       d«      | «      S )zm
    Decorator marking a test that requires quanto. These tests are skipped when quanto isn't installed.
    ztest requires quanto)r®   r¯   r   r±   s    r:   Úrequire_quantor    s%   € ð VŒ8×ÑÔ:Ó<Ð>TÓUÐV_Ó`Ð`r<   c                 óJ   —  t        j                  t        «       d«      | «      S )zu
    Decorator marking a test that requires accelerate. These tests are skipped when accelerate isn't installed.
    ztest requires accelerate)r®   r¯   r   r±   s    r:   Úrequire_accelerater    s%   € ð VŒ8×ÑÔ6Ó8Ð:TÓUÐV_Ó`Ð`r<   c                 ó   ‡ — ˆ fd„}|S )zž
    Decorator marking a test that requires PEFT backend with a specific version, this would require some specific
    versions of PEFT and transformers.
    c                 ó$  •— t        «       xre t        j                  t        j                  t        j                  j                  d«      «      j
                  «      t        j                  ‰«      kD  } t        j                  |d‰› �«      | «      S )Nr%   z9test requires PEFT backend with the version greater than )r   r   ÚparseÚ	importlibÚmetadataÚbase_versionr®   r¯   )r²   Úcorrect_peft_versionÚpeft_versions     €r:   rÆ   z/require_peft_version_greater.<locals>.decorator)  s~   ø€ Ü0Ó2ò  (´w·}±}Ü�M‰Mœ)×,Ñ,×4Ñ4°VÓ<Ó=×JÑJó8
ä�M‰M˜,Ó'ñ8(Ðð
Œx×"Ñ"Ø Ð$]Ð^jÐ]kÐ"ló
à
óð 	r<   rÇ   )r  rÆ   s   ` r:   Úrequire_peft_version_greaterr  #  s   ø€ ôð Ðr<   c                 ó   ‡ — ˆ fd„}|S )zž
    Decorator marking a test that requires transformers with a specific version, this would require some specific
    versions of PEFT and transformers.
    c                 ó$  •— t        «       xre t        j                  t        j                  t        j                  j                  d«      «      j
                  «      t        j                  ‰«      kD  } t        j                  |d‰› �«      | «      S )Nr&   z9test requires transformers with the version greater than )r"   r   r  r  r  r  r®   r¯   )r²   Úcorrect_transformers_versionÚtransformers_versions     €r:   rÆ   z7require_transformers_version_greater.<locals>.decorator:  sƒ   ø€ Ü'@Ó'Bò (0ÄwÇ}Á}Ü�M‰Mœ)×,Ñ,×4Ñ4°^ÓDÓE×RÑRóH
ä�M‰MÐ.Ó/ñH0Ð$ð
Œx×"Ñ"Ø(ØGÐH\ÐG]Ð^ó
ð óð 	r<   rÇ   )r!  rÆ   s   ` r:   Ú$require_transformers_version_greaterr"  4  s   ø€ ôð Ðr<   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó&  •— t        «       xre t        j                  t        j                  t        j                  j                  d«      «      j
                  «      t        j                  ‰«      kD  } t        j                  |d‰› d�«      | «      S )NÚ
acceleratez7Test requires accelerate with the version greater than r0   )r   r   r  r  r  r  r®   r¯   )r²   Úcorrect_accelerate_versionÚaccelerate_versions     €r:   rÆ   z5require_accelerate_version_greater.<locals>.decoratorG  s„   ø€ Ü%<Ó%>ò &.Ä7Ç=Á=Ü�M‰Mœ)×,Ñ,×4Ñ4°\ÓBÓC×PÑPóD
ä�M‰MÐ,Ó-ñD.Ð"ð
Œx×"Ñ"Ø&Ð*aÐbtÐauÐuvÐ(wó
à
óð 	r<   rÇ   )r'  rÆ   s   ` r:   Ú"require_accelerate_version_greaterr(  F  ó   ø€ ôð Ðr<   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó&  •— t        «       xre t        j                  t        j                  t        j                  j                  d«      «      j
                  «      t        j                  ‰«      kD  } t        j                  |d‰› d�«      | «      S )NÚbitsandbytesz9Test requires bitsandbytes with the version greater than r0   )r   r   r  r  r  r  r®   r¯   )r²   Úcorrect_bnb_versionÚbnb_versions     €r:   rÆ   z7require_bitsandbytes_version_greater.<locals>.decoratorS  s�   ø€ Ü7Ó9ò '¼g¿m¹mÜ�M‰Mœ)×,Ñ,×4Ñ4°^ÓDÓE×RÑRó?
ä�M‰M˜+Ó&ñ?'Ðð
Œx×"Ñ"ØÐ#\Ð]hÐ\iÐijÐ!kó
à
óð 	r<   rÇ   )r.  rÆ   s   ` r:   Ú$require_bitsandbytes_version_greaterr/  R  r)  r<   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó  •— t        j                  t        j                  t        j                  j                  d«      «      j                  «      t        j                  ‰«      kD  } t        j                  |d‰› d�«      | «      S )NÚhuggingface_hubz<Test requires huggingface_hub with the version greater than r0   )r   r  r  r  r  r®   r¯   )r²   Úcorrect_hf_hub_versionÚhf_hub_versions     €r:   rÆ   z1require_hf_hub_version_greater.<locals>.decorator_  sx   ø€ Ü!(§¡Ü�M‰Mœ)×,Ñ,×4Ñ4Ð5FÓGÓH×UÑUó"
ä�M‰M˜.Ó)ñ"*Ðð
Œx×"Ñ"Ø"Ð&bÐcqÐbrÐrsÐ$tó
à
óð 	r<   rÇ   )r4  rÆ   s   ` r:   Úrequire_hf_hub_version_greaterr5  ^  r)  r<   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó&  •— t        «       xre t        j                  t        j                  t        j                  j                  d«      «      j
                  «      t        j                  ‰«      k\  } t        j                  |d‰› d�«      | «      S )NÚggufz1Test requires gguf with the version greater than r0   )r   r   r  r  r  r  r®   r¯   )r²   Úcorrect_gguf_versionÚgguf_versions     €r:   rÆ   z8require_gguf_version_greater_or_equal.<locals>.decoratork  s�   ø€ Ü0Ó2ò  )´w·}±}Ü�M‰Mœ)×,Ñ,×4Ñ4°VÓ<Ó=×JÑJó8
ä�]‰]˜<Ó(ñ8)Ðð
Œx×"Ñ"Ø Ð$UÐVbÐUcÐcdÐ"eó
à
óð 	r<   rÇ   )r:  rÆ   s   ` r:   Ú%require_gguf_version_greater_or_equalr;  j  r)  r<   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó&  •— t        «       xre t        j                  t        j                  t        j                  j                  d«      «      j
                  «      t        j                  ‰«      k\  } t        j                  |d‰› d�«      | «      S )NÚtorchaoz0Test requires torchao with version greater than r0   )r    r   r  r  r  r  r®   r¯   )r²   Úcorrect_torchao_versionÚtorchao_versions     €r:   rÆ   z;require_torchao_version_greater_or_equal.<locals>.decoratorw  ó�   ø€ Ü"6Ó"8ò #,¼W¿]¹]Ü�M‰Mœ)×,Ñ,×4Ñ4°YÓ?Ó@×MÑMó>
ä�]‰]˜?Ó+ñ>,Ðð
Œx×"Ñ"Ø#Ð'WÐXgÐWhÐhiÐ%jó
à
óð 	r<   rÇ   )r@  rÆ   s   ` r:   Ú(require_torchao_version_greater_or_equalrB  v  r)  r<   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó&  •— t        «       xre t        j                  t        j                  t        j                  j                  d«      «      j
                  «      t        j                  ‰«      k\  } t        j                  |d‰› d�«      | «      S )NÚmodeloptz1Test requires modelopt with version greater than r0   )r   r   r  r  r  r  r®   r¯   )r²   Úcorrect_nvidia_modelopt_versionÚmodelopt_versions     €r:   rÆ   z<require_modelopt_version_greater_or_equal.<locals>.decoratorƒ  s„   ø€ Ü*FÓ*Hò +-ÌWÏ]É]Ü�M‰Mœ)×,Ñ,×4Ñ4°ZÓ@ÓA×NÑNóN
ä�]‰]Ð+Ó,ñN-Ð'ð
Œx×"Ñ"Ø+Ð/`ÐaqÐ`rÐrsÐ-tó
à
óð 	r<   rÇ   )rG  rÆ   s   ` r:   Ú)require_modelopt_version_greater_or_equalrH  ‚  r)  r<   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó&  •— t        «       xre t        j                  t        j                  t        j                  j                  d«      «      j
                  «      t        j                  ‰«      k\  } t        j                  |d‰› d�«      | «      S )NÚkernelsz0Test requires kernels with version greater than r0   )r   r   r  r  r  r  r®   r¯   )r²   Úcorrect_kernels_versionÚkernels_versions     €r:   rÆ   z;require_kernels_version_greater_or_equal.<locals>.decorator�  rA  r<   rÇ   )rM  rÆ   s   ` r:   Ú(require_kernels_version_greater_or_equalrN  Ž  r)  r<   c                 óD   —  t        j                  t         d«      | «      S )zJ
    Decorator marking a test that will be skipped after PEFT backend
    z%test skipped in favor of PEFT backendr
  r±   s    r:   Údeprecate_after_peft_backendrP  š  s%   € ð ^Œ8×ÑÔ#3Ð3Ð5\Ó]Ð^gÓhÐhr<   c                  óZ   — t         j                  } | j                  | j                  }}||fS ©N)ÚsysÚversion_infoÚmajorÚminor)Úsys_inforU  rV  s      r:   Úget_python_versionrX  ¡  s(   € Ü×Ñ€HØ—>‘> 8§>¡>ˆ5€EØ�%ˆ<Ðr<   ÚarryÚ
local_pathc                 ó”  — t        | t        «      �r|�Rt        || j                  d«      d   | j                  d«      d   | j                  d«      d   «      j	                  «       S | j                  d«      s| j                  d«      rUt        j                  | t        ¬«      }|j                  «        t        j                  t        |j                  «      «      } | S t        j                  j!                  | «      rt        j                  | «      } | S t#        d| › d	�«      ‚t        | t        j$                  «      r	 | S t#        d
«      ‚)NÚ/éûÿÿÿéþÿÿÿrT   úhttp://úhttps://©ÚtimeoutúIIncorrect path or url, URLs must start with `http://` or `https://`, and ú is not a valid pathzjIncorrect format used for numpy ndarray. Should be an url linking to an image, a local path, or a ndarray.)rH   r`   r   rf   r~   Ú
startswithÚrequestsr]   r   Úraise_for_statusr?   Úloadr   Úcontentr[   rz   Úisfiler1   Úndarray)rY  rZ  Úresponses      r:   Ú
load_numpyrm  §  s  € Ü�$œÕØÐ!ä˜
 D§J¡J¨s£O°BÑ$7¸¿¹ÀC»ÈÑ9LÈdÏjÉjÐY\ËoÐ^`ÑNaÓb×kÑkÓmÐmØ�_‰_˜YÔ'¨4¯?©?¸:Ô+FÜ—|‘| DÔ2KÔLˆHØ×%Ñ%Ô'Ü—7‘7œ7 8×#3Ñ#3Ó4Ó5ˆDð €Kô �W‰W�^‰^˜DÔ!Ü—7‘7˜4“=ˆDð €Kô Ø[Ð\`Ð[aÐauÐvóð ô 
�Dœ"Ÿ*™*Ô	%Øð €Kô ðó
ð 	
r<   TÚurlÚmap_locationÚweights_onlyc                 ó²   — t        j                  | t        ¬«      }|j                  «        t	        j
                  t        |j                  «      ||¬«      }|S )Nra  )ro  rp  )rf  r]   r   rg  r2   rh  r   ri  )rn  ro  rp  rl  rY  s        r:   Úload_ptrr  Á  sB   € Ü�|‰|˜CÔ)BÔC€HØ×ÑÔÜ�:‰:”g˜h×.Ñ.Ó/¸lÐYeÔf€DØ€Kr<   Úimagec                 óR  — t        | t        «      r´| j                  d«      s| j                  d«      rDt        j                  j                  t        j                  | dt        ¬«      j                  «      } n€t        j                  j                  | «      r t        j                  j                  | «      } nAt        d| › d�«      ‚t        | t        j                  j                  «      r| } nt        d«      ‚t        j                  j                  | «      } | j!                  d«      } | S )	zÙ
    Loads `image` to a PIL Image.

    Args:
        image (`str` or `PIL.Image.Image`):
            The image to convert to the PIL Image format.
    Returns:
        `PIL.Image.Image`:
            A PIL Image.
    r_  r`  T)Ústreamrb  rc  rd  zdIncorrect format used for image. Should be an url linking to an image, a local path, or a PIL image.ÚRGB)rH   r`   re  ÚPILÚImagerg   rf  r]   r   Úrawr[   rz   rj  r1   ÚImageOpsÚexif_transposeÚconvert)rs  s    r:   Ú
load_imager}  È  sß   € ô �%œÔØ×Ñ˜IÔ&¨%×*:Ñ*:¸:Ô*FÜ—I‘I—N‘N¤8§<¡<°¸dÔLeÔ#f×#jÑ#jÓk‰EÜ�W‰W�^‰^˜EÔ"Ü—I‘I—N‘N 5Ó)‰EäØ[Ð\aÐ[bÐbvÐwóð ô 
�Eœ3Ÿ9™9Ÿ?™?Ô	+Ø‰äØró
ð 	
ô �L‰L×'Ñ'¨Ó.€EØ�M‰M˜%Ó €EØ€Lr<   Ú
batch_sizec                 ó–  — | j                   \  }}d„ ||fD «       \  }}| j                  ||ft        j                  j                  ¬«      } t        j                  | «      j                  t
        j                  «      dz  } t        j                  | d    j                  dddd«      g|z  «      } t        j                  | «      } d| z  d	z
  S )
Nc              3   ó,   K  — | ]  }||d z  z
  –— Œ y­w)é   NrÇ   )Ú.0Úxs     r:   Ú	<genexpr>z#preprocess_image.<locals>.<genexpr>é  s   è ø€ Ð&™v˜!ˆA��A‘�I™vùs   ‚)Úresampleg     ào@r   é   r   é   g       @r>   )ÚsizeÚresizerw  rx  ÚLANCZOSr?   ÚarrayÚastyperd   ÚvstackÚ	transposer2   r_   )rs  r~  ÚwÚhs       r:   Úpreprocess_imager‘  ç  s¬   € Ø�:‰:�D€A€qÙ&  1™vÓ&�D€A€qØ�L‰L˜!˜Q˜¬#¯)©)×*;Ñ*;ˆLÓ<€EÜ�H‰H�U‹O×"Ñ"¤2§:¡:Ó.°Ñ6€EÜ�I‰I�u˜T‘{×,Ñ,¨Q°°1°aÓ8Ð9¸JÑFÓG€EÜ×Ñ˜UÓ#€EØ�‰;˜ÑÐr<   Úoutput_gif_pathc                 ó„   — |€ t        j                  d¬«      j                  }| d   j                  |d| dd  ddd¬«       |S )	Nz.gif©Úsuffixr   Tr   Féd   )Úsave_allÚappend_imagesÚoptimizeÚdurationÚloop)ÚtempfileÚNamedTemporaryFiler§   Úsave)rs  r’  s     r:   Úexport_to_gifrŸ  ñ  sS   € ØÐÜ"×5Ñ5¸VÔD×IÑIˆà	ˆ!�H‡M�MØØØ˜A˜B�iØØØð ô ð Ðr<   c              #   ó^   K  — t        j                  | «      }|–— |j                  «        y ­wrR  )ÚioÚBufferedWriterÚflush)Úraw_frt   s     r:   Úbuffered_writerr¥     s$   è ø€ ä
×Ñ˜%Ó €AØ
‚GØ‡G�G…Iùs   ‚+-Úoutput_ply_pathc           	      ó¨  — |€ t        j                  d¬«      j                  }| j                  j	                  «       j                  «       j                  «       }| j                  j                  «       j                  «       }t        j                  dD �cg c];  }| j                  |   j	                  «       j                  «       j                  «       ‘Œ= c}d¬«      }t        t        |d«      «      5 }|j                  d«       |j                  d	«       |j                  t        d
t        |«      › d�d«      «       |j                  d«       |j                  d«       |j                  d«       |�3|j                  d«       |j                  d«       |j                  d«       |�9|j                  t        dt        |«      › d�d«      «       |j                  d«       |j                  d«       |� |dz  j!                  «       j#                  t$        «      }t'        |j)                  «       |j)                  «       «      D ��cg c]  \  }}g |¢|¢­‘Œ }}}t+        j,                  d«      }	|D ]   }
|j                   |	j.                  |
Ž «       Œ" nHt+        j,                  d«      }	|j)                  «       D ]   }|j                   |	j.                  |Ž «       Œ" |�U|j)                  «       D ]-  }|j                   |	j.                  t        |«      g|¢­Ž «       Œ/ t+        j,                  d«      }	ddd«       |S c c}w c c}}w # 1 sw Y   |S xY w)z&
    Write a PLY file for a mesh.
    Nz.plyr”  rv  r   ©ÚaxisÚwbs   ply
s    format binary_little_endian 1.0
zelement vertex rU   Úasciis   property float x
s   property float y
s   property float z
s   property uchar red
s   property uchar green
s   property uchar blue
zelement face s%   property list uchar int vertex_index
s   end_header
g‡ÙÎ÷ïo@z<3f3Bz<3fz<B3I)rœ  r�  r§   Úvertsra   r,   ÚnumpyÚfacesr?   ry   Úvertex_channelsr¥  rg   ÚwriteÚbytesÚlenÚroundrŒ  ÚintÚzipÚtolistÚstructÚStructÚpack)Úmeshr¦  Úcoordsr®  rƒ  Úrgbrt   ÚcoordÚverticesÚformatÚitemÚvertexÚtris                r:   Úexport_to_plyrÃ    sÂ  € ð ÐÜ"×5Ñ5¸VÔD×IÑIˆà�Z‰Z×ÑÓ ×$Ñ$Ó&×,Ñ,Ó.€FØ�J‰J�N‰NÓ×"Ñ"Ó$€EÜ
�(‰(ÉEÓRÉEÀq�D×(Ñ(¨Ñ+×2Ñ2Ó4×8Ñ8Ó:×@Ñ@ÕBÈEÑRÐYZÔ
[€Cä	œ˜o¨tÓ4Ô	5¸Ø	�‰�ÔØ	�‰Ð4Ô5Ø	�‰”˜¬¨F« }°BÐ7¸ÓAÔBØ	�‰Ð%Ô&Ø	�‰Ð%Ô&Ø	�‰Ð%Ô&Øˆ?Ø�G‰GÐ+Ô,Ø�G‰GÐ-Ô.Ø�G‰GÐ,Ô-ØÐØ�G‰G”E˜M¬#¨e«*¨°RÐ8¸'ÓBÔCØ�G‰GÐ=Ô>Ø	�‰�Ô àˆ?Ø˜‘=×'Ñ'Ó)×0Ñ0´Ó5ˆCô #&Ø—M‘M“OØ—J‘J“Lô#ôñ#‘J�E˜3ð �%�˜#“ð#ð ñ ô —]‘] 7Ó+ˆFÛ �Ø—‘˜˜Ÿ™ TÐ*Õ+ñ !ô —]‘] 5Ó)ˆFØ Ÿ-™-ž/�Ø—‘˜˜Ÿ™ VÐ,Õ-ð *ð ÐØ—|‘|–~�Ø—‘˜˜Ÿ™¤C¨£HÐ3¨sÒ3Õ4ð &ä—]‘] 6Ó*ˆF÷I 
6ðJ ÐùòO Sùó(÷% 
6ðJ Ðús'   ÂA L<Ã2EMÉMÉCMÍMÍMÚoutput_obj_pathc                 óâ  — |€ t        j                  d¬«      j                  }| j                  j	                  «       j                  «       j                  «       }| j                  j                  «       j                  «       }t        j                  dD �cg c];  }| j                  |   j	                  «       j                  «       j                  «       ‘Œ= c}d¬«      }t        |j                  «       |j                  «       «      D ��cg c]  \  }} dj                  g |¢|¢­Ž ‘Œ }}}|j                  «       D �	cg c]B  }	dj                  t        |	d   dz   «      t        |	d   dz   «      t        |	d	   dz   «      «      ‘ŒD }}	|D �
cg c]  }
d
|
z   ‘Œ	 c}
|z   }t        |d«      5 }|j!                  dj#                  |«      «       d d d «       y c c}w c c}}w c c}	w c c}
w # 1 sw Y   y xY w)Nz.objr”  rv  r   r¨  z{} {} {} {} {} {}z
f {} {} {}r   r‡  zv r�  rU   )rœ  r�  r§   r¬  ra   r,   r­  r®  r?   ry   r¯  rµ  r¶  r¿  r`   rg   Ú
writelinesri   )rº  rÄ  r¬  r®  rƒ  Úvertex_colorsr½  Úcolorr¾  rÂ  rÁ  Úcombined_datart   s                r:   Úexport_to_objrÊ  :  s­  € ØÐÜ"×5Ñ5¸VÔD×IÑIˆà�J‰J×ÑÓ×#Ñ#Ó%×+Ñ+Ó-€EØ�J‰J�N‰NÓ×"Ñ"Ó$€Eä—H‘HÑV[Ó\ÑV[ÐQR˜d×2Ñ2°1Ñ5×<Ñ<Ó>×BÑBÓD×JÑJÕLÐV[Ñ\ÐcdÔe€MäGJÈ5Ï<É<Ë>Ð[h×[oÑ[oÓ[qÔGrôÙGr±|°u¸eÐ"Ð×"Ñ"Ð2 EÐ2¨EÔ2ÐGrð ñ ð `e×_kÑ_kÔ_mÓnÑ_mÐX[ˆ\× Ñ ¤ S¨¡V¨a¡Z£´#°c¸!±f¸q±j³/Ä3ÀsÈ1ÁvÐPQÁzÃ?ÕSÐ_m€EÐná19Ó:± v�T˜F“]°Ñ:¸UÑB€Mä	ˆo˜sÔ	# qØ	�‰�T—Y‘Y˜}Ó-Ô.÷ 
$Ð	#ùò ]ùóùò oùâ:ç	#Ð	#ús&   ÂA GÄGÄ;AGÆG Æ&!G%Ç%G.Úvideo_framesÚoutput_video_pathc                 ó´  — t        «       rdd l}n$t        t        d   d   j	                  d«      «      ‚|€ t        j                  d¬«      j                  } |j                  dŽ }| d   j                  \  }}}|j                  ||d||f¬	«      }t        t        | «      «      D ]2  }|j                  | |   |j                  «      }	|j                  |	«       Œ4 |S )
Nr   Úopencvr   Úexport_to_videoz.mp4r”  Úmp4vr�  )ÚfpsÚ	frameSize)r   Úcv2ÚImportErrorr   r¿  rœ  r�  r§   ÚVideoWriter_fourccr¤   ÚVideoWriterrž   r²  ÚcvtColorÚCOLOR_RGB2BGRr°  )
rË  rÌ  rÓ  Úfourccr�  r�  ÚcÚvideo_writerÚiÚimgs
             r:   rÏ  rÏ  N  sÒ   € ÜÔÜäÔ*¨8Ñ4°QÑ7×>Ñ>Ð?PÓQÓRÐRØÐ Ü$×7Ñ7¸vÔF×KÑKÐà#ˆS×#Ñ# VÐ,€FØ˜1‰o×#Ñ#�G€A€qˆ!Ø—?‘?Ð#4°fÀ!ÐPQÐSTÈv�?ÓV€LÜ”3�|Ó$Ö%ˆØ�l‰l˜<¨™?¨C×,=Ñ,=Ó>ˆØ×Ñ˜3Õð &ð Ðr<   c                 óÚ   — d}| j                  d«      sN| j                  d«      s=t        j                  j                  |t        j
                  j                  | «      «      } t        | «      S )NzEhttps://huggingface.co/datasets/fusing/diffusers-testing/resolve/mainr_  r`  )re  r[   rz   ri   Úurllibr  Úquoterm  )rz   Úbase_urls     r:   Úload_hf_numpyrâ  _  sL   € ØV€Hà�?‰?˜9Ô%¨d¯o©o¸jÔ.IÜ�w‰w�|‰|˜H¤f§l¡l×&8Ñ&8¸Ó&>Ó?ˆä�dÓÐr<   c                 óV   — d}|t         vr| j                  |ddd¬«       dt         |<   yy)zö
    This function is to be called from `conftest.py` via `pytest_addoption` wrapper that has to be defined there.

    It allows loading both `conftest.py` files at once without causing a failure due to adding the same `pytest`
    option.

    z--make-reportsÚstoreFzSgenerate report files. The value of this option is used as a prefix to report names)Úactionr”   Úhelpr   N)Úpytest_opt_registeredÚ	addoption)ÚparserÚoptions     r:   Úpytest_addoption_sharedrë  n  sC   € ð €FØÔ*Ñ*Ø×ÑØØØØfð	 	ô 	
ð )*Ô˜fÒ%ð +r<   c           
      ó  — ddl m} t        |«      sd}| j                  }|j	                  «       }|j
                  j                  }| j                  }d}t        |«      j                  dd¬«       dD �ci c]  }||› d|› d	|› d
�“Œ }	}g }
| j                  j                  «       D ]'  }|D ]   }t        |d«      sŒ|
j                  |«       Œ" Œ) |
rÀ|
j                  d„ d¬«       t        |	d   d«      5 }d}|j!                  d«       t#        |
«      D ]s  \  }}|j$                  |k  r%|j!                  t        |
«      |z
  › d|› d�«        n<|j!                  |j$                  d›d|j&                  d›d|j(                  › d�«       Œu ddd«       d„ }d|j
                  _        t        |	d   d«      5 } |||«      | _        | j-                  «        ddd«       t        |	d   d«      5 } |||«      | _         || «       ddd«       d|j
                  _        t        |	d   d«      5 } |||«      | _        | j-                  «        ddd«       t        |	d    d«      5 } |||«      | _        | j/                  «        ddd«       t        |	d!   d«      5 } |||«      | _        | j1                  «        | j1                  «        ddd«       d"| _        t        |	d#   d«      5 } |||«      | _        | j3                  «        ddd«       t        |	d$   d«      5 } |||«      | _        | j5                  «        ddd«       t        |	d%   d«      5 } |||«      | _        | j7                  «        ddd«       || _        || _        ||j
                  _        yc c}w # 1 sw Y   �ŒxY w# 1 sw Y   �ŒÖxY w# 1 sw Y   �ŒµxY w# 1 sw Y   �Œ{xY w# 1 sw Y   �ŒRxY w# 1 sw Y   �ŒxY w# 1 sw Y   ŒèxY w# 1 sw Y   Œ¾xY w# 1 sw Y   Œ”xY w)&a�  
    Generate multiple reports at the end of test suite run - each report goes into a dedicated file in the current
    directory. The report files are prefixed with the test suite name.

    This function emulates --duration and -rA pytest arguments.

    This function is to be called from `conftest.py` via `pytest_terminal_summary` wrapper that has to be defined
    there.

    Args:
    - tr: `terminalreporter` passed from `conftest.py`
    - id: unique id like `tests` or `examples` that will be incorporated into the final reports filenames - this is
      needed as some jobs have multiple runs of pytest, so we can't have them overwrite each other.

    NB: this functions taps into a private _pytest API and while unlikely, it could break should
    pytest do internal changes - also it calls default internal methods of terminalreporter which
    can be hijacked by various `pytest-` plugins and interfere.

    r   )Úcreate_terminal_writerrw   ÚreportsT)ÚparentsÚexist_ok)	Ú	durationsÚerrorsÚfailures_longÚfailures_shortÚfailures_lineÚpassesÚstatsÚsummary_shortÚwarningsr\  r«   z.txtrš  c                 ó   — | j                   S rR  )rš  )rƒ  s    r:   Ú<lambda>z.pytest_terminal_summary_main.<locals>.<lambda>¹  s   €  §¢r<   )rM   Úreverserñ  r�  gš™™™™™©?zslowest durations
z durations < z secs were omittedz02.2fzs z<8Ú rU   Nc           	      ód  — | j                  d«      }|sy | j                  dd«       |D ]…  }| j                  |«      }| j                  d|dd¬«       t        j                  dd|j
                  d	t        j                  t        j                  z  «      }| j                  j                  |«       Œ‡ y )
NÚfailedÚ=zFAILURES SHORT STACKr«   T)ÚredÚboldz.*_ _ _ (_ ){10,}_ _ rV   r   )
Ú
getreportsÚ	write_sepÚ_getfailureheadlineÚreÚsubÚlongreprtextÚMÚSÚ_twÚline)Útrrî  ÚrepÚmsgÚlongreprs        r:   Úsummary_failures_shortz<pytest_terminal_summary_main.<locals>.summary_failures_shortÃ  s“   € à—-‘- Ó)ˆÙØØ
�‰�SÐ0Ô1ÛˆCØ×(Ñ(¨Ó-ˆCØ�L‰L˜˜c t°$ˆLÔ7ä—v‘vÐ6¸¸C×<LÑ<LÈaÔQS×QUÑQUÔXZ×X\ÑX\ÑQ\Ó]ˆHØ�F‰F�K‰K˜Õ!ñ r<   Úautoró  rô  r  rõ  rò  rù  ÚwPpsxXEfrö  rø  r÷  )Ú_pytest.configrí  r²  ÚconfigÚget_terminal_writerrê  ÚtbstyleÚreportcharsr   Úmkdirr÷  rª   ÚhasattrrŸ   Úsortrg   r°  Ú	enumeraterš  ÚwhenÚnodeidr  Úsummary_failuresÚsummary_errorsÚsummary_warningsÚsummary_passesÚshort_test_summaryÚsummary_stats)r  Úidrí  r  Úorig_writerÚorig_tbstyleÚorig_reportcharsÚdirÚkÚreport_filesÚdlistÚreplistr  rt   Údurations_minrÜ  r  s                    r:   Úpytest_terminal_summary_mainr/  �  s¹  € õ( 6äˆrŒ7Øˆà�Y‰Y€FØ×,Ñ,Ó.€KØ—=‘=×(Ñ(€LØ—~‘~Ðà
€CÜˆƒI‡O�O˜D¨4€OÔ0ñ

óñ

ˆAð 	
ˆcˆU�!�B�4�q˜˜˜4Ð Ñ ð

ð ð ð$ €EØ—8‘8—?‘?Ö$ˆÛˆCÜ�s˜JÕ'Ø—‘˜SÕ!ñ ð %ñ Ø�
‰
Ñ+°Tˆ
Ô:Ü�,˜{Ñ+¨SÔ1°QØ ˆMØ�G‰GÐ)Ô*Ü# EÖ*‘��3Ø—<‘< -Ò/Ø—G‘Gœs 5›z¨A™~Ð.¨m¸M¸?ÐJ\Ð]Ô^ÙØ—‘˜3Ÿ<™<¨Ð.¨b°·±¸"°¸Q¸s¿z¹z¸lÈ"ÐMÕNð	 +÷ 2ò"ð( #€F‡M�MÔÜ	ˆl˜?Ñ+¨SÔ	1°QÙ'¨°Ó2ˆŒØ
×ÑÔ÷ 
2ô
 
ˆlÐ+Ñ,¨cÔ	2°aÙ'¨°Ó2ˆŒÙ˜rÔ"÷ 
3ð #€F‡M�MÔÜ	ˆl˜?Ñ+¨SÔ	1°QÙ'¨°Ó2ˆŒØ
×ÑÔ÷ 
2ô 
ˆl˜8Ñ$ cÔ	*¨aÙ'¨°Ó2ˆŒØ
×ÑÔ÷ 
+ô 
ˆl˜:Ñ&¨Ô	,°Ù'¨°Ó2ˆŒØ
×ÑÔØ
×ÑÔ÷ 
-ð
  €B„NÜ	ˆl˜8Ñ$ cÔ	*¨aÙ'¨°Ó2ˆŒØ
×ÑÔ÷ 
+ô 
ˆl˜?Ñ+¨SÔ	1°QÙ'¨°Ó2ˆŒØ
×ÑÔ÷ 
2ô 
ˆl˜7Ñ# SÔ	)¨QÙ'¨°Ó2ˆŒØ
×ÑÔ÷ 
*ð
 €B„FØ%€B„NØ(€F‡M�MÕùò}÷2 2Ñ1ú÷< 
2Ñ	1ú÷
 
3Ñ	2ú÷
 
2Ñ	1ú÷ 
+Ñ	*ú÷ 
-Ñ	,ú÷ 
+Ð	*ú÷ 
2Ð	1ú÷ 
*Ð	)úss   Á4NÃ4BNÆ4N'Ç*N4È)OÉOÊ/OË"O(ÌO4ÍP ÎN$Î'N1Î4N>ÏOÏOÏO%Ï(O1Ï4O=Ð P	Úmax_attemptsÚwait_before_retryÚdescriptionc                 ó   ‡ ‡‡‡— ˆˆˆ ˆfd„Š‰S )a  
    To decorate flaky tests (methods or entire classes). They will be retried on failures.

    Args:
        max_attempts (`int`, *optional*, defaults to 5):
            The maximum number of attempts to retry the flaky test.
        wait_before_retry (`float`, *optional*):
            If provided, will wait that number of seconds before retrying the test.
        description (`str`, *optional*):
            A string to describe the situation (what / where / why is flaky, link to GH issue/PR comments, errors,
            etc.)
    c                 ó0  •‡ — t        j                  ‰ «      r^t        ‰ j                  j	                  «       «      D ]6  \  }}t        |«      sŒ|j                  d«      sŒ$t        ‰ | ‰|«      «       Œ8 ‰ S t        j                  ‰ «      ˆˆˆ ˆfd„«       }|S )NÚtestc            	      ó  •— d}|‰k  r		  ‰| i |¤ŽS  ‰| i |¤ŽS # t         $ r]}d‰xs ‰j                  ›d|› d‰› d|› �}t        |t        j                  ¬«       ‰�t        j                  ‰«       |dz  }Y d }~nd }~ww xY w|‰k  rŒ€Œx)Nr   z[FLAKY] z failed on attempt r\  z: rX   )Ú	ExceptionÚ__name__rh   rS  ÚstderrÚtimeÚsleep)	r8   r9   Úretry_countÚerrr  r2  r0  Úobjr1  s	        €€€€r:   Úwrapperz,is_flaky.<locals>.decorator.<locals>.wrapper  s´   ø€ àˆKØ Ò,ð
%Ù Ð/¨Ñ/Ð/ñ ˜Ð' Ñ'Ð'øô !ò %à" ;Ò#>°#·,±,Ð"Að B-Ø-8¨M¸¸<¸.ÈÈ3È%ðQð ô ˜#¤C§J¡JÕ/Ø(Ð4ÜŸ
™
Ð#4Ô5Ø 1Ñ$•Kûð%úð  Ó,øs   Š š	B £AA;Á;B )
rx   ÚisclassÚlistÚ__dict__rG   Úcallablere  ÚsetattrÚ	functoolsÚwraps)r>  Ú	attr_nameÚ
attr_valuer?  rÆ   r2  r0  r1  s   `   €€€€r:   rÆ   zis_flaky.<locals>.decorator  s‚   ù€ ä�?‰?˜3ÔÜ)-¨c¯l©l×.@Ñ.@Ó.BÖ)CÑ%�	˜:Ü˜JÕ'¨I×,@Ñ,@ÀÕ,Hä˜C ©I°jÓ,AÕBð *Dð ˆJô 
�‰˜Ó	ö	(ó 
ð	(ð" ˆr<   rÇ   )r0  r1  r2  rÆ   s   ```@r:   Úis_flakyrI    s   û€ ÷ð< Ðr<   c                 óL  — |€)t        t        j                  j                  dd«      «      }d}t	        j
                  |«      }|j                  d«      }|j                  d«      }|j                  ||¬«       |j                  ||||f¬«      }|j                  «        	 |j                  |¬«      }	|j                  «        |j                  |¬«       	d   �| j                  |	d   › «       yy# t        $ r+}
|j                  «        | j                  |
«       Y d}
~
Œ]d}
~
ww xY w)	aÆ  
    To run a test in a subprocess. In particular, this can avoid (GPU) memory issue.

    Args:
        test_case (`unittest.TestCase`):
            The test that will run `target_func`.
        target_func (`Callable`):
            The function implementing the actual testing logic.
        inputs (`dict`, *optional*, defaults to `None`):
            The inputs that will be passed to `target_func` through an (input) queue.
        timeout (`int`, *optional*, defaults to `None`):
            The timeout (in seconds) that will be passed to the input and output queues. If not specified, the env.
            variable `PYTEST_TIMEOUT` will be checked. If still `None`, its value will be set to `600`.
    NÚPYTEST_TIMEOUTiX  Úspawnr   ra  )Útargetr8   Úerror)r´  r[   r\   r]   ÚmultiprocessingÚget_contextÚQueueÚJoinableQueueÚputÚProcessÚstartÚ	task_doner7  Ú	terminateÚfailri   )r²   Útarget_funcÚinputsrb  Ústart_methohdÚctxÚinput_queueÚoutput_queueÚprocessÚresultsÚes              r:   Úrun_test_in_subprocessrb  3  s  € ð €Ü”b—j‘j—n‘nÐ%5°sÓ;Ó<ˆà€MÜ
×
%Ñ
% mÓ
4€Cà—)‘)˜A“,€KØ×$Ñ$ QÓ'€Lð ‡O�O�F G€OÔ,à�k‰k °KÀÈwÐ3WˆkÓX€GØ‡M�M„OðØ×"Ñ"¨7Ð"Ó3ˆØ×ÑÔ ð ‡L�L˜€LÔ!àˆwÑÐ#Ø�‰˜' 'Ñ*Ð+Õ-ð $øô ò Ø×ÑÔØ�‰�q×Ñûðús   Â"C/ Ã/	D#Ã8!DÄD#c                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)ÚCaptureLoggeraG  
    Args:
    Context manager to capture `logging` streams
        logger: 'logging` logger object
    Returns:
        The captured output is available via `self.out`
    Example:
    ```python
    >>> from diffusers import logging
    >>> from diffusers.testing_utils import CaptureLogger

    >>> msg = "Testing 1, 2, 3"
    >>> logging.set_verbosity_info()
    >>> logger = logging.get_logger("diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.py")
    >>> with CaptureLogger(logger) as cl:
    ...     logger.info(msg)
    >>> assert cl.out, msg + "
"
    ```
    c                 ó†   — || _         t        «       | _        t        j                  | j                  «      | _        d| _        y )NrV   )Úloggerr   r¡  ÚloggingÚStreamHandlerÚshÚout)Úselfrf  s     r:   Ú__init__zCaptureLogger.__init__s  s/   € ØˆŒÜ“*ˆŒÜ×'Ñ'¨¯©Ó0ˆŒØˆ�r<   c                 óP   — | j                   j                  | j                  «       | S rR  )rf  Ú
addHandlerri  ©rk  s    r:   Ú	__enter__zCaptureLogger.__enter__y  s   € Ø�‰×Ñ˜tŸw™wÔ'Øˆr<   c                 óŒ   — | j                   j                  | j                  «       | j                  j	                  «       | _        y rR  )rf  ÚremoveHandlerri  r¡  Úgetvaluerj  )rk  Úexcs     r:   Ú__exit__zCaptureLogger.__exit__}  s,   € Ø�‰×!Ñ! $§'¡'Ô*Ø—7‘7×#Ñ#Ó%ˆ�r<   c                 ó"   — d| j                   › d�S )Nz
captured: rU   )rj  ro  s    r:   Ú__repr__zCaptureLogger.__repr__�  s   € Ø˜DŸH™H˜: RÐ(Ð(r<   N)r8  Ú
__module__Ú__qualname__Ú__doc__rl  rp  ru  rw  rÇ   r<   r:   rd  rd  ^  s   „ ñò(òò&ó)r<   rd  c                  óF   — ddl m}  t        j                  d«        | «       S )zœ
    Helper function for reproducible behavior during distributed training. See
    - https://pytorch.org/docs/stable/notes/randomness.html for pytorch
    r   )Úenable_full_determinismzªenable_full_determinism has been moved to diffusers.utils.torch_utils. Importing from diffusers.utils.testing_utils is deprecated and will be removed in a future version.)Útorch_utilsr|  rf  Úwarning)Ú_enable_full_determinisms    r:   r|  r|  …  s%   € õ
 Qä
‡N�Nð	nôñ $Ó%Ð%r<   c                  óF   — ddl m}  t        j                  d«        | «       S )Nr   )Údisable_full_determinismz«disable_full_determinism has been moved to diffusers.utils.torch_utils. Importing from diffusers.utils.testing_utils is deprecated and will be removed in a future version.)r}  r�  rf  r~  )Ú_disable_full_determinisms    r:   r�  r�  “  s"   € ÝRä
‡N�Nð	nôñ %Ó&Ð&r<   c                 ó.  — t        «       sydd l} |j                  | «      } 	  |j                  d|j                  ¬«      j                  | «      } |j                  ||«      }y# t        $ r'}| j                  dk(  rt        d|› �«      ‚Y d }~yd }~ww xY w)NFr   ©r‡  r‡  ©rœ   Tr+   z‹You have passed a device of type 'cuda' which should work with 'fp16', but 'cuda' does not seem to be correctly installed on your machine: )
r   r2   ÚdeviceÚzerosÚfloat16rc   Úmulr7  Útyper1   ©r†  r2   rƒ  r«   ra  s        r:   rã   rã   ž  ó    € ÜÔØãàˆU�\‰\˜&Ó!€FðØˆE�K‰K˜ e§m¡mÔ4×7Ñ7¸Ó?ˆØˆE�I‰I�a˜‹OˆØøäò Ø�;‰;˜&Ò Üð ^ð  _`ð  ^að  bóð ô ûðúó   £A A$ Á$	BÁ-BÂBc                 ó.  — t        «       sydd l} |j                  | «      } 	  |j                  d|j                  ¬«      j                  | «      } |j                  ||«      }y# t        $ r'}| j                  dk(  rt        d|› �«      ‚Y d }~yd }~ww xY w)NFr   r„  r…  Tr+   z‹You have passed a device of type 'cuda' which should work with 'fp64', but 'cuda' does not seem to be correctly installed on your machine: )
r   r2   r†  r‡  Úfloat64rc   r‰  r7  rŠ  r1   r‹  s        r:   rç   rç   ´  rŒ  r�  )r+   r$   r,   r-   r”   c                   ó   — y©Nr   rÇ   rÇ   r<   r:   rû  rû  Ú  ó   € �qr<   c                   ó   — yr‘  rÇ   rÇ   r<   r:   rû  rû  Û  r’  r<   Úreset_peak_memory_statsÚmax_memory_allocatedÚsynchronizer†  Údispatch_tablec                 óT   — | |vr |d   |i |¤ŽS ||    }t        |«      s|S  ||i |¤ŽS )Nr”   )rC  )r†  r—  r8   r9   Úfns        r:   Ú_device_agnostic_dispatchrš    sI   € Ø�^Ñ#Ø(ˆ~˜iÑ(¨$Ð9°&Ñ9Ð9à	˜Ñ	€Bô �BŒ<Øˆ	áˆtÐ�vÑÐr<   Úseedc                 óJ   — ddl m} t        j                  d«        || |«      S )Nr   )Úbackend_manual_seedz—backend_manual_seed has been moved to diffusers.utils.torch_utils. diffusers.utils.testing_utils is deprecated and will be removed in a future version.)r}  r�  rf  r~  )r†  r›  Ú_backend_manual_seeds      r:   r�  r�    s&   € ÝHä
‡N�Nð	_ôñ   ¨Ó-Ð-r<   c                 óH   — ddl m} t        j                  d«        || «      S )Nr   )Úbackend_synchronizez—backend_synchronize has been moved to diffusers.utils.torch_utils. diffusers.utils.testing_utils is deprecated and will be removed in a future version.)r}  r   rf  r~  )r†  Ú_backend_synchronizes     r:   r   r     ó$   € ÝHä
‡N�Nð	_ôñ   Ó'Ð'r<   c                 óH   — ddl m} t        j                  d«        || «      S )Nr   )Úbackend_empty_cachez—backend_empty_cache has been moved to diffusers.utils.torch_utils. diffusers.utils.testing_utils is deprecated and will be removed in a future version.)r}  r¤  rf  r~  )r†  Ú_backend_empty_caches     r:   r¤  r¤  '  r¢  r<   c                 óH   — ddl m} t        j                  d«        || «      S )Nr   )Úbackend_device_countz˜backend_device_count has been moved to diffusers.utils.torch_utils. diffusers.utils.testing_utils is deprecated and will be removed in a future version.)r}  r§  rf  r~  )r†  Ú_backend_device_counts     r:   r§  r§  1  s$   € ÝJä
‡N�Nð	_ôñ ! Ó(Ð(r<   c                 óH   — ddl m} t        j                  d«        || «      S )Nr   )Úbackend_reset_peak_memory_statsz£backend_reset_peak_memory_stats has been moved to diffusers.utils.torch_utils. diffusers.utils.testing_utils is deprecated and will be removed in a future version.)r}  rª  rf  r~  )r†  Ú _backend_reset_peak_memory_statss     r:   rª  rª  ;  s$   € Ý`ä
‡N�Nð	_ôñ ,¨FÓ3Ð3r<   c                 óH   — ddl m} t        j                  d«        || «      S )Nr   )Ú"backend_reset_max_memory_allocatedz¦backend_reset_max_memory_allocated has been moved to diffusers.utils.torch_utils. diffusers.utils.testing_utils is deprecated and will be removed in a future version.)r}  r­  rf  r~  )r†  Ú#_backend_reset_max_memory_allocateds     r:   r­  r­  E  s$   € Ýfä
‡N�Nð	_ôñ /¨vÓ6Ð6r<   c                 óH   — ddl m} t        j                  d«        || «      S )Nr   )Úbackend_max_memory_allocatedz backend_max_memory_allocated has been moved to diffusers.utils.torch_utils. diffusers.utils.testing_utils is deprecated and will be removed in a future version.)r}  r°  rf  r~  )r†  Ú_backend_max_memory_allocateds     r:   r°  r°  O  s$   € ÝZä
‡N�Nð	_ôñ )¨Ó0Ð0r<   c                 óH   — ddl m} t        j                  d«        || «      S )Nr   )r÷   z�backend_supports_training has been moved to diffusers.utils.torch_utils. diffusers.utils.testing_utils is deprecated and will be removed in a future version.)r}  r÷   rf  r~  )r†  Ú_backend_supports_trainings     r:   r÷   r÷   [  s$   € ÝTä
‡N�Nð	_ôñ & fÓ-Ð-r<   Údevice_fn_dictÚattribute_namec                 óš   — 	 t        t        |«      }|| t        <   y # t        $ r%}d| vrt        d|› dt        › d�«      |‚Y d }~y d }~ww xY w)Nr”   Ú`z` not found in 'z)' and no default fallback function found.)ÚgetattrÚdevice_spec_modulerÑ   ÚAttributeErrorÚdevice_spec_path)r´  rµ  Úspec_fnra  s       r:   Úupdate_mapping_from_specr½  h  sb   € ð		äÔ0°.ÓAˆGØ+2ˆNœ<Ò(øÜò 	à Ñ.Ü$Ø˜Ð'Ð'7Ô8HÐ7IÐIrÐsóàðô /ûð	ús   ‚ œ	A
¥AÁA
ÚDIFFUSERS_TEST_DEVICE_SPECzCSpecified path to device specification file is not found. Received z.pyz9Provided device spec file is not a Python file! Received z.Device spec file did not contain `DEVICE_NAME`z?Mismatch between environment variable `DIFFUSERS_TEST_DEVICE` 'z' and device found in spec 'z'
zKEither unset `DIFFUSERS_TEST_DEVICE` or ensure it matches device spec name.ÚMANUAL_SEED_FNÚEMPTY_CACHE_FNÚDEVICE_COUNT_FNÚSUPPORTS_TRAININGÚRESET_PEAK_MEMORY_STATS_FNÚRESET_MAX_MEMORY_ALLOCATED_FNÚMAX_MEMORY_ALLOCATED_FNc                  óò   — t         st        r/ddl} | j                  j	                  «       \  }}t        rd|fS d|fS t
        r/ddl} | j                  j	                  «       d   }d}||z  dz	  }d|fS t        dfS )	z,
    Get environment device properties.
    r   NÚrocmr+   Úarchitecturel       üé    r$   )ÚIS_CUDA_SYSTEMÚIS_ROCM_SYSTEMr2   r+   Úget_device_capabilityÚIS_XPU_SYSTEMr$   rÑ   )r2   rU  r«   ÚarchÚgen_maskÚgens         r:   rí   rí   œ  s€   € õ
 �Ûà—:‘:×3Ñ3Ó5‰ˆˆqÝØ˜E�?Ð"à˜E�?Ð"Ý	Ûð �y‰y×.Ñ.Ó0°Ñ@ˆØ%ˆØ�h‰ 2Ñ%ˆØ�sˆ|Ðä˜dÐ#Ð#r<   )Ú_GO_LC_SUPPORTED_PYTORCH_LAYERS)Ú_GROUP_ID_LAZY_LEAFÚ_compute_group_hashÚ"_find_parent_module_in_module_dictÚ/_gather_buffers_with_no_group_offloading_parentÚ2_gather_parameters_with_no_group_offloading_parentÚmoduleÚoffload_to_disk_pathÚoffload_typeÚnum_blocks_per_groupc           
      óº  ‡— t        «       }dt        dt        fˆfd„}|dk(  �r|€t        d«      ‚g }| j                  «       D ]«  \  }}t	        |t
        j                  j                  t
        j                  j                  f«      s|j                  | «       ŒVt        dt        |«      |«      D ]=  }	||	|	|z    }
|
sŒ|› d|	› d|	t        |
«      z   dz
  › �}|j                   ||«      «       Œ? Œ­ |D ]0  } |j                   || j                  j                  › d	�«      «       Œ2 |S |d
k(  �r| j                  «       D ]-  \  }}t	        |t         «      sŒ|j                   ||«      «       Œ/ | j                  «       D ��ch c]  \  }}t	        |t         «      sŒ|’Œ }}}t#        | |«      }t%        | |«      }||z   }|rli }t'        | j                  «       «      }|D ].  \  }}t)        ||«      }||vrg ||<   ||   j                  |«       Œ0 |D ]  }|j                   ||«      «       Œ |j                   |t*        «      «       |S t        d|› �«      ‚c c}}w )NÚgroup_idrƒ   c                 ób   •— t        | «      }t        j                  j                  ‰d|› d�«      S )NÚgroup_z.safetensors)rÓ  r[   rz   ri   )rÜ  Ú
short_hashrØ  s     €r:   Úget_hashed_filenamez<_get_expected_safetensors_files.<locals>.get_hashed_filenameÌ  s,   ø€ Ü,¨XÓ6ˆJÜ—7‘7—<‘<Ð 4¸¸z¸lÈ,Ð6WÓXÐXr<   Úblock_levelzCnum_blocks_per_group must be provided for 'block_level' offloading.r   r«   r   Ú_unmatched_groupÚ
leaf_levelzUnsupported offload_type: )rI   r`   r1   Únamed_childrenrH   r2   ÚnnÚ
ModuleListÚ
SequentialrŸ   rž   r²  ÚaddÚ	__class__r8  Únamed_modulesrÑ  rÖ  rÕ  ÚdictrÔ  rÒ  )r×  rØ  rÙ  rÚ  Úexpected_filesrà  Úunmatched_modulesr§   Ú	submodulerÜ  Úcurrent_modulesrÜ  ÚsmÚmodules_with_group_offloadingÚ
parametersÚbuffersÚall_orphansÚparent_to_tensorsÚmodule_dictÚtensor_namer«   Úparent_names    `                    r:   Ú_get_expected_safetensors_filesrù  Ä  s�  ø€ ô ›ˆð	Y¬#ð 	Y´#õ 	Yð ˜=Ó(Ø#Ð+Ü Ð!fÓgÐgð !#ÐØ#)×#8Ñ#8Ö#:‘��iÜ! )¬e¯h©h×.AÑ.AÄ5Ç8Á8×CVÑCVÐ-WÔXØ%×,Ñ,¨VÔ4Øä˜q¤# i£.Ð2FÖG�AØ&/°°AÐ8LÑ4LÐ&M�OÙ*Ø Ø"&  q¨¨¨1¨Q´°_Ó1EÑ-EÈÑ-IÐ,JÐK�HØ"×&Ñ&Ñ':¸8Ó'DÕEñ Hð $;ó ,�Ø×"Ñ"Ñ#6¸&×:JÑ:J×:SÑ:SÐ9TÐTdÐ7eÓ#fÕgð ,ðF ÐðA ˜\Ó)à#)×#7Ñ#7Ö#9‘��iÜ˜iÔ)HÕIà"×&Ñ&Ñ':¸4Ó'@ÕAð $:ð &,×%9Ñ%9Ô%;ô-Ù%;™˜˜r¼zÈ"ÔNmÕ?n’Ð%;ð *ñ -ô LÈFÐTqÓrˆJÜEÀfÐNkÓlˆGà$ wÑ.ˆKÙØ$&Ð!Ü" 6×#7Ñ#7Ó#9Ó:�Û&1‘N�K Ü"DÀ[ÐR]Ó"^�KØ"Ð*;Ñ;Ø9;Ð)¨+Ñ6Ø% kÑ2×9Ñ9¸+ÕFð	 '2ó $5�Kà"×&Ñ&Ñ':¸;Ó'GÕHð $5ð ×ÑÑ2Ô3FÓGÔHð
 Ðô Ð9¸,¸ÐHÓIÐIùó--s   ÆIÆIc                 ó  — t         j                  j                  |«      syt        | |||«      }t	        t        j
                  t         j                  j                  |d«      «      «      }||z
  }||z
  }| xr | }|||fS )N)FNNz*.safetensors)r[   rz   Úisdirrù  rI   Úglobri   )	r×  rØ  rÙ  rÚ  rì  Úactual_filesÚmissing_filesÚextra_filesÚ
is_corrects	            r:   Ú _check_safetensors_serializationr    s‚   € ô �w‰w�}‰}Ð1Ô2Ø$ä8ØÐ(¨,Ð8Ló
ˆô œ4Ÿ9™9¤R§W¡W§\¡\Ð2FÈÓ%XÓYÓZˆØ&¨Ñ5ˆØ" ^Ñ3ˆà&Ð&Ò:¨{¨?ˆ
Ø˜;¨Ð5Ð5r<   c                   óh   — e Zd Zdefd„Zededefd„«       Zededede	fd„«       Z
d
dedefd„Zd„ Zy	)ÚExpectationsrƒ   c                 ó4   — | j                  t        «       «      S )zX
        Find best matching expectation based on environment device properties.
        )Úfind_expectationrí   ro  s    r:   Úget_expectationzExpectations.get_expectation  s   € ð ×$Ñ$Ô%:Ó%<Ó=Ð=r<   rM   c                 ó&   — t        d„ | D «       «      S )Nc              3   ó$   K  — | ]  }|d u –— Œ
 y ­wrR  rÇ   )r‚  Úps     r:   r„  z*Expectations.is_default.<locals>.<genexpr>%  s   è ø€ Ð*¡c �1˜”9¡cùs   ‚)Úall©rM   s    r:   Ú
is_defaultzExpectations.is_default#  s   € äÑ*¡cÓ*Ó*Ð*r<   Úotherc                 ó¬   — | \  }}|\  }}d}||k(  r|dz  }n|dv r	|dv r|dz  }||k(  r|�|dz  }t         j                  |«      r|dz  }t        |«      S )aÈ  
        Returns score indicating how similar two instances of the `Properties` tuple are. Points are calculated using
        bits, but documented as int. Rules are as follows:
            * Matching `type` gives 8 points.
            * Semi-matching `type`, for example cuda and rocm, gives 4 points.
            * Matching `major` (compute capability major version) gives 2 points.
            * Default expectation (if present) gives 1 points.
        r   r�  )r+   rÇ  é   r‡  r   )r  r  r´  )rM   r  Údevice_typerU  Úother_device_typeÚother_majorÚscores          r:   r  zExpectations.score'  s‚   € ð  #Ñˆ�eØ+0Ñ(Ð	˜KàˆØÐ+Ò+Ø�V‰O‰EØÐ,Ñ,Ð1BÐFVÑ1VØ�U‰NˆEà�KÒ KÐ$;Ø�T‰MˆEä×"Ñ" 5Ô)Ø�S‰LˆEä�5‹zÐr<   c                 ó¬   ‡— t        | j                  j                  «       ˆfd„¬«      \  }}t        j	                  ‰|«      dk(  rt        d‰› �«      ‚|S )zU
        Find best matching expectation based on provided device properties.
        c                 ó6   •— t         j                  ‰| d   «      S r‘  )r  r  )rƒ  rM   s    €r:   rû  z/Expectations.find_expectation.<locals>.<lambda>F  s   ø€ ÄL×DVÑDVÐWZÐ\]Ð^_Ñ\`ÔDar<   r  r   z"No matching expectation found for )r5   r›   rG   r  r  r1   )rk  rM   Ú
result_keyÚresults    `  r:   r  zExpectations.find_expectationB  sO   ø€ ô  # 4§9¡9§?¡?Ó#4Ó:aÔbÑˆ�Vä×Ñ˜c :Ó.°!Ò3ÜÐAÀ#ÀÐGÓHÐHàˆr<   c                 ó   — | j                   › S rR  )r›   ro  s    r:   rw  zExpectations.__repr__M  s   € Ø—)‘)�Ðr<   N)©NN)r8  rx  ry  r	   r  ÚstaticmethodÚDevicePropertiesÚboolr  r´  r  r  rw  rÇ   r<   r:   r  r    su   „ ð> ó >ð ð+Ð(ð +¨Tò +ó ð+ð ðÐ#ð Ð,<ð Àò ó ðñ4	Ð$4ð 	Èó 	ór<   r  )NNztest_corrections.txtÚexpected_slicerR  )F)r>   NN)NT)é   NNr  )ìrE  rü  r  Úimportlib.metadatarx   r¡  rg  rO  r[   r    r  r·  rS  rœ  r:  r®   Úurllib.parserß  Úcollectionsr   Ú
contextlibr   r   r   Úpathlibr   Útypingr   r	   r
   r   r­  r?   Ú	PIL.Imagerw  ÚPIL.ImageOpsrf  Únumpy.linalgr   Ú	packagingr   Ú	constantsr   Úimport_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r2   ÚhiprË  r+   rÊ  r¸  rÍ  ÚRandomr�   r8  rf  r~  r  r  r  Ú_required_peft_versionÚ_required_transformers_versionr  r´  Úgetenvr'   r\   ÚbackendÚimport_moduler«   ÚModuleNotFoundErrorra  rÑ   r†  ÚRuntimeErrorÚinforÕ   r$   Ú__version__Úis_torch_higher_equal_than_1_12r  ÚbackendsÚmps_backend_registeredr-   r}  r.   r;   rD   rO   ru   r‚   r‘   r–   r°   rµ   r¸   r¬   r³   r¶   r¹   r¼   r¿   rÉ   rÎ   rÒ   rØ   rÚ   rß   rá   rä   rè   rð   rõ   rø   rû   rý   rÿ   r  r  r  r  r  r  r  r  r  r  r"  r(  r/  r5  r;  rB  rH  rN  rP  rX  r`   rk  rm  r  rr  rx  r}  r‘  rA  rŸ  r¥  rÃ  rÊ  rÏ  râ  rç  rë  r/  r¡   rI  rb  rd  r|  r�  rã   rç   ÚBACKEND_SUPPORTS_TRAININGÚempty_cacheÚBACKEND_EMPTY_CACHErÝ   ÚBACKEND_DEVICE_COUNTÚmanual_seedÚBACKEND_MANUAL_SEEDr”  ÚBACKEND_RESET_PEAK_MEMORY_STATSÚreset_max_memory_allocatedÚ"BACKEND_RESET_MAX_MEMORY_ALLOCATEDr•  ÚBACKEND_MAX_MEMORY_ALLOCATEDr–  ÚBACKEND_SYNCHRONIZErë  rš  r�  r   r¤  r§  rª  r­  r°  r÷   r½  r»  Úis_filer1   ÚindexÚimport_namer¹  ÚDEVICE_NAMEÚdevice_namerº  r  Útupler  Ú	lru_cacherí   ÚDevicePropertiesUserDictÚdiffusers.hooks._commonrÑ  Ú diffusers.hooks.group_offloadingrÒ  rÓ  rÔ  rÕ  rÖ  rå  ÚModulerù  r  r  rÇ   r<   r:   Ú<module>rO     sØ
  ðÛ Û Û Û Û Û 	Û Û Û 	Û Û 	Û Û 
Û Û Û Û Ý  Ý %ß  Ý ß 4Ó 4ã Û Û Û Ý Ý å 0÷÷ ÷ ÷ ÷ ñ õ*  ñ ÔÛà—]‘]×&Ñ&¨dÐ2€NØ—]‘]×'Ñ'¨tÐ3€NÙ˜EŸM™M¨5°$Ó7¸tÐC�Mà€NØ€NØ€MàˆV�]‰]‹_€
á	�HÓ	€Ø ‡�ðbôñ +Ó,ò °°·±Ø€G‡M�M�)×$Ñ$×,Ñ,¨VÓ4Ó5×BÑBó2à€G‡M�M�%Óñ2Ð ñ ";Ó!<ò "ÀÀÇÁØ€G‡M�M�)×$Ñ$×,Ñ,¨^Ó<Ó=×JÑJóBà€G‡M�M�&ÓñBÐ ð *ÒLÐ.LÐ Ù�Y�R—Y‘YÐ/°Ó4Ó5€áÕÛð   2§:¡:Ñ-Ø—*‘*Ð5Ñ6ˆð	Ø'�	×'Ñ'¨Ó0ˆAð  "§*¡*Ñ,Ø—z‘zÐ"9Ñ:ˆð	à�—‘˜\Ó*ˆAð
 	�‰Ð/°¨~Ð>Õ?à�:‰:×"Ñ"Ô$Ø!‰LØ�Y‰Y×#Ñ#Ô%Ø ‰Là ˆLØ*7¨'¯-©-ØˆG�M‰M˜%×+Ñ+Ó,×9Ñ9ó+
àˆW�]‰]˜6Ó"ñ+#Ð'ñ +á%,¨U¯^©^¸UÓ%CÐ"Ù%;ÀÇÁ×@RÑ@R×@_Ñ@_Ô@a™5ÐhtˆLå=òòòð2 ØØ#Ø)óOó4ð.9˜#ó 9óñ  & j¸%Ô@€Ù(¨ÀÔFÐ Ù(¨ÀÔFÐ óQò KòQòWòYòò	ò	òò	òòhòòòòò(ò:òcò
[òYò\ò]òiò]òZòUòeòaòaòò"ò$	ò	ò	ò	ò	ò	ò	òiòñ�S˜2Ÿ:š:Ñ%ð °3¸±:ð ÈÏÊó ñ4�ð  C¨$¡Jð ÀTÈDÁ[ó ð�c˜CŸIšIŸOšOÑ+ð °·	²	·²ó ð>˜CŸIšIð °3ó ñ˜˜cŸišiŸošoÑ.ð Àð ÐPSó ð ñó ðñ0¨ó 0ñf/¨ó /ñ( $ r§z¢zÑ"2ð Àsð ÐVYó ð"˜2Ÿ:š:ó ð Ð ò*ò&~)ñD,˜3ð ,°u¸t±|ð ,ÐY\Ð_cÑYcó ,ó`(.÷V$)ñ $)òN&ò'òò,ñ. Õà)-°dÀ4ÐPUÐbfÑ gÐð —
‘
×&Ò&Ø�y‰y×$Ò$ØØ�y‰y×$Ò$ØñÐð —
‘
×'Ò'Ø�y‰y×%Ò%ÙÙØñÐð —
‘
×&Ò&Ø�y‰y×$Ò$Ø× Ò Ø�y‰y×$Ò$Ø×$Ò$ñÐð —
‘
×2Ò2Ù�u—y‘yÐ";¸TÓBØØØñ'Ð#ð —
‘
×5Ò5Ù�u—y‘yÐ";¸TÓBØØØñ*Ð&ð —
‘
×/Ò/Ù�u—y‘yÐ"8¸$Ó?ØØØñ$Ð ð —
‘
×&Ò&Ù�u—y‘y -°Ó6ØØØñÐð cð ¸4ÀÀXÀÑ;Nó ð. ð .¨3ó .ð( ó (ð( ó (ð) ó )ð4¨Có 4ð7¨só 7ð1¨ó 1ð. có .ñ Ôð
°°c¸8°mÑ1Dð 
ÐVYó 
ð $ r§z¡zÑ1ØŸ:™:Ð&BÑCÐÙÐ$Ó%×-Ò-Ô/ÙÐbÐcsÐbtÐuÓvÐvð	tØ*Ð+JÐ-=×-CÒ-CÀEÓ-JÐKˆKð 5˜Y×4Ñ4°[ÓAÐð	SØ,×8Ò8ˆKð # b§j¡jÑ0°\À[Ò5PØSÐT`ÐSaÐa}ð  Jð  ~Kð  KNð  OˆCØÐ`Ñ`ˆCÙ˜S“/Ð!à"ˆñ 	!Ð!4Ð6FÔGÙ Ð!4Ð6FÔGÙ Ð!5Ð7HÔIÙ Ð!:Ð<OÔPÙ Ð!@ÐB^Ô_Ù Ð!CÐEdÔeÙ Ð!=Ð?XÔYð ˜˜t™ S¨4¡ZÐ/Ñ0Ð ð ×Òð$Ð/ò $ó ð$ñ0 Ø'Ð(8¸#Ð(=Ñ>Ñà'ÐáÔÝG÷õ ð ,0ñ	BØ—’—’ðBà!ðBð ðBð " D™jð	Bð
 
ˆS‰óBðP ,0ñ	6Ø—’—’ð6à!ð6ð ð6ð " D™jð	6ð
 
ó6ô(2Ð+õ 2øðA. #ò 	Ù%Ø=¸g¸Yð G7Ø78°cð;óð ðûð	ûð ò 	ÙØdÐeqÐdrÐsóàðûð	ûðh( ò 	tÙÐXÐYiÐXjÐkÓlÐrsÐsûð	tûð ò 	SÙ Ð!QÓRÐRð	SúsT   É
b> É:c Ý4c3 Þd â>cãcãcãc0ãc+ã+c0ã3d	ã8däd	äd