+
    Lj                     l    R t ^ RIHt ^ RIHtHt ^ RIHt ^ RIt	^RI
HtHt R R lt ! R R	]4      tR# )
z
Generic utilities
)OrderedDict)fieldsis_dataclassAnyN)is_torch_availableis_torch_versionc                $    V ^8  d   QhR\         /# )   return)bool)formats   "C/app/.local/lib/python3.14/site-packages/diffusers/utils/outputs.py__annotate__r      s     
% 
%D 
%    c                    \        4       '       d"   ^ RIp\        WP                  4      '       d   R# \        V \        P
                  4      # )z3
Tests if `x` is a `torch.Tensor` or `np.ndarray`.
NT)r   torch
isinstanceTensornpndarray)xr   s   & r   	is_tensorr      s3     a&&a$$r   c                      a a ] tR t^(t oRtV3R lR ltV3R lR ltR tR tR t	R	 t
V3R
 lR ltV3R lV 3R lltV 3R ltV 3R ltV3R lR ltRtVtV ;t# )
BaseOutputa  
Base class for all model outputs as dataclass. Has a `__getitem__` that allows indexing by integer or slice (like a
tuple) or strings (like a dictionary) that will ignore the `None` attributes. Otherwise behaves like a regular
Python dictionary.

> [!WARNING] > You can't unpack a [`BaseOutput`] directly. Use the [`~utils.BaseOutput.to_tuple`] method to convert
it to a tuple > first.
c                   < V ^8  d   QhRR/# r
   r   N )r   __classdict__s   "r   r   BaseOutput.__annotate__2   s      $ r   c                  a a \        4       '       d   ^ RIo\        RR4      '       dM   SP                  P                  P                  S SP                  P                  P                  V V3R l4       R# SP                  P                  P                  S SP                  P                  P                  V V3R lS P                   RS P                   2R7       R# R# )zRegister subclasses as pytree nodes.

This is necessary to synchronize gradients when using `torch.nn.parallel.DistributedDataParallel` with
`static_graph=True` with modules that output `ModelOutput` subclasses.
N<z2.2c                 Z   < S! R/ SP                   P                  P                  W4      B # Nr   utils_pytree_dict_unflattenvaluescontextclsr   s   &&r   <lambda>.BaseOutput.__init_subclass__.<locals>.<lambda>?   #    C,g%++2E2E2U2UV\2f,gr   c                 Z   < S! R/ SP                   P                  P                  W4      B # r#   r$   r(   s   &&r   r,   r-   E   r.   r   .)serialized_type_name)
r   torch.utils._pytreer   r%   r&   _register_pytree_node_dict_flattenregister_pytree_node
__module____name__)r+   r   s   f@r   __init_subclass__BaseOutput.__init_subclass__2   s     &U++##99KK''55g ##88KK''55g,/NN+;1S\\N)K	 9   r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   I   s     ) )t )r   c                2  a  \        S 4      p\        V4      '       g#   \        S P                  P                   R 24      h\        S V^ ,          P                  4      p\        ;QJ d&    V 3R lVR,           4       F  '       d   K   RM	  RM! V 3R lVR,           4       4      pV'       d7   \        V\        4      '       d!   VP                  4        F
  w  rEVS V&   K  	  R# V F.  p\        S VP                  4      pVf   K  VS VP                  &   K0  	  R# )z has no fields.c              3   T   <"   T F  p\        SVP                  4      R J x  K  	  R # 5iNgetattrname.0fieldselfs   & r   	<genexpr>+BaseOutput.__post_init__.<locals>.<genexpr>Q   s#     #dSc%GD%**$=$EScs   %(:   NNFTN)r   len
ValueError	__class__r7   r?   r@   allr   dictitems)rD   class_fieldsfirst_fieldother_fields_are_nonekeyvaluerC   vs   f       r   __post_init__BaseOutput.__post_init__I   s    d| <   7 78HIIdLO$8$89 ##dS_`bSc#d#dS_`bSc#d d ZT%B%B)//1
!S	 2 &D%**-='(D$ &r   c                H    \        R V P                  P                   R24      h)z$You cannot use ``__delitem__`` on a 
 instance.	ExceptionrJ   r7   rD   argskwargss   &*,r   __delitem__BaseOutput.__delitem__\   s#    >t~~?V?V>WWabccr   c                H    \        R V P                  P                   R24      h)z#You cannot use ``setdefault`` on a rW   rX   rZ   s   &*,r   
setdefaultBaseOutput.setdefault_   s#    =dnn>U>U=VV`abbr   c                H    \        R V P                  P                   R24      h)zYou cannot use ``pop`` on a rW   rX   rZ   s   &*,r   popBaseOutput.popb   s"    6t~~7N7N6OzZ[[r   c                H    \        R V P                  P                   R24      h)zYou cannot use ``update`` on a rW   rX   rZ   s   &*,r   updateBaseOutput.updatee   s#    9$..:Q:Q9RR\]^^r   c                &   < V ^8  d   QhRS[ RS[ /# )r
   kr   r   )r   r   s   "r   r   r   h   s     & &S &S &r   c                    \        V\        4      '       d"   \        V P                  4       4      pW!,          # V P	                  4       V,          # r=   )r   strrL   rM   to_tuple)rD   ri   
inner_dicts   && r   __getitem__BaseOutput.__getitem__h   s8    adjjl+J= ==?1%%r   c                *   < V ^8  d   QhRS[ RS[ RR/# )r
   r@   rR   r   Nr   )r   r   s   "r   r   r   o   s"     ) ) )C )D )r   c                t   < WP                  4       9   d   Ve   \        SV `	  W4       \        SV `  W4       R # r=   )keyssuper__setitem____setattr__)rD   r@   rR   rJ   s   &&&r   ru   BaseOutput.__setattr__o   s.    99;5#4G,D(r   c                D   < \         SV `  W4       \         SV `	  W4       R # r=   )rs   rt   ru   )rD   rQ   rR   rJ   s   &&&r   rt   BaseOutput.__setitem__u   s    C'C'r   c                   <a  \        S 4      '       g   \        SS `	  4       # \        SS `	  4       vrp\        ;QJ d     . V 3R  l\	        S 4       4       F  NK  	  5M! V 3R  l\	        S 4       4       4      pW.VO5# )c              3   P   <"   T F  p\        SVP                  4      x  K  	  R # 5ir=   r>   rA   s   & r   rE   (BaseOutput.__reduce__.<locals>.<genexpr>   s     IL5WT5::..Ls   #&)r   rs   
__reduce__tupler   )rD   callable_args	remainingr[   rJ   s   f    r   r|   BaseOutput.__reduce__{   sb    D!!7%''&+g&8&:#)uIF4LIuuIF4LII)	))r   c                4   < V ^8  d   QhRS[ S[R3,          /# )r
   r   .)r}   r   )r   r   s   "r   r   r      s     3 3%S/ 3r   c                   a  \         ;QJ d%    . V 3R lS P                  4        4       F  NK  	  5# ! V 3R lS P                  4        4       4      # )zQ
Convert self to a tuple containing all the attributes/keys that are not `None`.
c              3   6   <"   T F  pSV,          x  K  	  R # 5ir=   r   )rB   ri   rD   s   & r   rE   &BaseOutput.to_tuple.<locals>.<genexpr>   s     2kT!WWks   )r}   rr   )rD   s   fr   rl   BaseOutput.to_tuple   s3     u2diik2u2u2diik222r   r   )r7   r6   __qualname____firstlineno____doc__r8   rT   r]   r`   rc   rf   rn   ru   rt   r|   rl   __static_attributes____classdictcell____classcell__)rJ   r   s   @@r   r   r   (   sc      .) )&dc\_& &) )(*3 3 3r   r   )r   collectionsr   dataclassesr   r   typingr   numpyr   import_utilsr   r   r   r   r   r   r   <module>r      s.    $ ,   >
%^3 ^3r   