+
    åûjØL  ã                   óè   € ^ RI Ht ^ RIHtHtHtHt ^ RIt^ RI	t	^ RI	H
t
 ^ RIHt RR R lltR R	 ltR
 R ltR R ltRR R llt ! R R]
P&                  4      tRR R lltR R ltR R ltR# )é    ©Úwraps)ÚAnyÚCallableÚListÚOptionalN)Únn)Ú
functionalc                óP   € V ^8„  d   QhR\         R\        R\        P                  /# )é   ÚimageÚkeepdimÚreturn)r   ÚboolÚtorchÚTensor)Úformats   "ÚNC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\image\utils.pyÚ__annotate__r      s*   € ÷ E:ñ E:œ3ð E:¬ð E:¼¿¹ñ E:ó    c                ó^  € \        V \        P                  4      '       g   \        R\	        V 4       24      h\        V P                  4      ^8”  g   \        V P                  4      ^8  d   \        R4      hV P                  p\        P                  ! V 4      p\        V4      ^8X  d   VP                  ^ 4      pMY\        V4      ^8X  d   VP                  ^^ ^4      pM5\        V4      ^8X  d   VP                  ^ ^^^4      pRpM\        RV 24      hV'       g   VP                  ^ 4      # T# )ag  Convert a channels-last NumPy image or batch to a channels-first tensor view.

``tensor = image_to_tensor(array)`` takes an ``(H, W, C)``, ``(H, W)`` or ``(B, H, W, C)`` NumPy array and returns
a ``(C, H, W)`` or ``(B, C, H, W)`` tensor that shares the array's memory. The dtype and values are kept, so
``uint8`` stays in :math:`[0, 255]`.

Convention:
    - The last axis of a 3-D or 4-D array is always the channels. A channels-first ``(C, H, W)`` array is not
      detected: it is read as ``(H, W, C)``.
    - The tensor is a view of the array. An array with a negative stride, such as OpenCV's ``img[..., ::-1]``,
      raises ``ValueError``; pass ``img[..., ::-1].copy()``.
    - :ref:`Files and arrays <image-io-conventions>` relates it to torchvision's ``ToTensor``.

Args:
    image: image of the form ``(H, W, C)``, ``(H, W)`` or
        ``(B, H, W, C)``.
    keepdim: If ``False``, a 2-D or 3-D input gets a leading batch axis, ``(1, C, H, W)``. A 4-D input is
        always ``(B, C, H, W)``.

Returns:
    tensor of the form ``(C, H, W)`` for a 2-D or 3-D input with ``keepdim=True`` (a 2-D input has
    :math:`C = 1`), and ``(B, C, H, W)`` otherwise.

Raises:
    TypeError: if ``image`` is not a ``numpy.ndarray``.
    ValueError: if ``image`` is not two, three or four dimensional.

See Also:
    - :class:`ImageToTensor`: the module form, with ``keepdim=False`` by default.
    - :func:`image_list_to_tensor`: stacks a list of ``(H, W, C)`` images into a new ``(B, C, H, W)`` tensor.
    - :func:`tensor_to_image`: the other direction, back to a channels-last array.

Example:
    >>> img = np.ones((3, 3))
    >>> image_to_tensor(img).shape
    torch.Size([1, 3, 3])

    >>> img = np.ones((4, 4, 1))
    >>> image_to_tensor(img).shape
    torch.Size([1, 4, 4])

    >>> img = np.ones((4, 4, 3))
    >>> image_to_tensor(img, keepdim=False).shape
    torch.Size([1, 3, 4, 4])

z'Input type is not a numpy.ndarray. Got z9Input size must be a two, three or four dimensional arrayTz Cannot process image with shape )Ú
isinstanceÚnpÚndarrayÚ	TypeErrorÚtypeÚlenÚshapeÚ
ValueErrorr   Ú
from_numpyÚ	unsqueezeÚpermute)r   r   Úinput_shapeÚtensors   &&  r   Úimage_to_tensorr%      s   € ô^ �eœRŸZ™Z×(Ò(ÜÐAÄ$ÀuÃ+ÀÐOÓPÐPä
ˆ5�;‰;Ó˜!Ôœs 5§;¡;Ó/°!Ô3ÜÐTÓUÐUà—+‘+€KÜ ×+Ò+¨EÓ2€Fä
ˆ;Ó˜1Ôà×!Ñ! !Ó$‰Ü	ˆ[Ó	˜QÔ	à—‘  1 aÓ(‰Ü	ˆ[Ó	˜QÔ	à—‘  1 a¨Ó+ˆØ‰äÐ;¸K¸=ÐIÓJÐJç&-ˆ6×Ñ˜AÓÐ9°6Ð9r   c                óZ   € V ^8„  d   QhR\         \        ,          R\        P                  /# )r   Úimagesr   )r   r   r   r   )r   s   "r   r   r   d   s"   € ÷ 4<ñ 4<¤¤c¥ð 4<¬u¯|©|ñ 4<r   c                ó¼  a€ V '       g   \        R4      h. pV  FG  p\        P                  ! V4      '       g    \        P                  ! V4      pVP                  V4       KI  	  V^ ,          P                  o\        S4      ^8w  d   \        R4      h\        ;QJ d    V3R lV 4       F  '       g   K   RM	  RM! V3R lV 4       4      '       d   \        R4      h\        P                  ! V^ R7      P                  ^ ^^^4      #   \          dJ    \	        T\
        P                  4      '       g   h \        P                  ! TP                  4       4      p ELi ; i)aœ  Stack a list of same-shape ``(H, W, C)`` images into a new ``(B, C, H, W)`` tensor.

``batch = image_list_to_tensor(images)`` takes a non-empty list of ``(H, W, C)`` NumPy arrays or tensors, all of one
shape, and returns them stacked into a new ``(B, C, H, W)`` tensor that keeps their values. Unlike
:func:`image_to_tensor`, it copies, so arrays with negative strides, such as ``img[..., ::-1]``, are accepted.

Convention:
    - The dtype is the promotion of the images' dtypes, so ``uint8`` and ``float32`` images give ``float32``.
    - All images must be on one device, arrays counting as CPU; the result keeps it.

Args:
    images: list of images, each of the form ``(H, W, C)``, all of the same shape.

Returns:
    tensor of the form ``(B, C, H, W)``.

Raises:
    ValueError: if the list is empty, an image is not three dimensional, or the shapes differ.
    RuntimeError: if the images are on different devices.

See Also:
    - :func:`image_to_tensor`: converts one array, or an already stacked ``(B, H, W, C)`` array, as a view.

Example:
    >>> imgs = [np.ones((4, 4, 1)), np.zeros((4, 4, 1))]
    >>> image_list_to_tensor(imgs).shape
    torch.Size([2, 1, 4, 4])

zInput list of images is emptyz$Each image must have shape (H, W, C)c              3   ó@   <"  € T F  qP                   S8g  x € K  	  R # 5i©N)r   )Ú.0Úimgr   s   & €r   Ú	<genexpr>Ú'image_list_to_tensor.<locals>.<genexpr>”   s   øé € Ð
2© #�9‰9˜Ö«ùs   ƒTFz#All images must have the same shape©Údim)r   r   Ú	is_tensorÚ	as_tensorr   r   r   ÚcopyÚappendr   r   ÚanyÚstackr"   )r'   Úimages_tr,   r   s   &  @r   Úimage_list_to_tensorr8   d   s  ø€ ÷< ÜÐ8Ó9Ð9à€HÛˆÜ�Š˜s×#Ò#ð2Ü—o’o cÓ*�ð 	�‰˜Öñ ð �Q�K×Ñ€EÜ
ˆ5ƒz�Q„ÜÐ?Ó@Ð@ß
ƒsÔ
2©Ó
2‡s‡s‚sÔ
2©Ó
2×2Ò2ÜÐ>Ó?Ð?ô �;Š;�x QÔ'×/Ñ/°°1°a¸Ó;Ð;øô ô 2ä! #¤r§z¡z×2Ò2ØÜ—o’o c§h¡h£jÓ1“ð	2ús   ¹DÄAEÅEc                óX   € V ^8„  d   QhR\         P                  R\         P                  /# ©r   r$   r   ©r   r   )r   s   "r   r   r   ›   s"   € ÷ ñ ”U—\‘\ð ¤e§l¡lñ r   c                óF  € \        V \        P                  4      '       g   \        R\	        V 4       24      h\        V P                  4      ^8  d   \        RV P                   24      h\        V P                  4      ^8X  d   V P                  ^ 4      p \        V P                  4      ^8X  d   V P                  ^ 4      p \        V P                  4      ^8”  dH   V P                  RV P                  R,          V P                  R,          V P                  R,          4      p V # )z¬Convert a PyTorch tensor image to BCHW format.

Args:
    tensor (torch.Tensor): image of the form ``(*, H, W)``.

Returns:
    input tensor of the form ``(B, C, H, W)``.

ú&Input type is not a torch.Tensor. Got z@Input size must be a two, three or four dimensional tensor. Got éÿÿÿÿéýÿÿÿéþÿÿÿ©
r   r   r   r   r   r   r   r   r!   Úreshape©r$   s   &r   Ú_to_bchwrD   ›   sà   € ô �fœeŸl™l×+Ò+ÜÐ@ÄÀfÃÀÐOÓPÐPä
ˆ6�<‰<Ó˜1ÔÜÐ[Ð\b×\hÑ\hÐ[iÐjÓkÐkä
ˆ6�<‰<Ó˜AÔØ×!Ñ! !Ó$ˆä
ˆ6�<‰<Ó˜AÔØ×!Ñ! !Ó$ˆä
ˆ6�<‰<Ó˜1ÔØ—‘  F§L¡L°Õ$4°f·l±lÀ2Õ6FÈÏÉÐUWÕHXÓYˆà€Mr   c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# r:   r;   )r   s   "r   r   r   ·   s"   € ÷ ñ ”e—l‘lð ¤u§|¡|ñ r   c                ój  € \        V \        P                  4      '       g   \        R\	        V 4       24      h\        V P                  4      ^8  d   \        RV P                   24      h\        V P                  4      ^8X  d   V P                  ^ 4      p \        V P                  4      ^8X  d   V P                  ^ 4      p \        V P                  4      ^8”  dZ   V P                  RV P                  R,          V P                  R,          V P                  R,          V P                  R,          4      p V # )z³Convert a PyTorch tensor image to BCDHW format.

Args:
    tensor (torch.Tensor): image of the form ``(*, D, H, W)``.

Returns:
    input tensor of the form ``(B, C, D, H, W)``.

r=   zAInput size must be a three, four or five dimensional tensor. Got r>   éüÿÿÿr?   r@   rA   rC   s   &r   Ú	_to_bcdhwrH   ·   sï   € ô �fœeŸl™l×+Ò+ÜÐ@ÄÀfÃÀÐOÓPÐPä
ˆ6�<‰<Ó˜1ÔÜÐ\Ð]c×]iÑ]iÐ\jÐkÓlÐlä
ˆ6�<‰<Ó˜AÔØ×!Ñ! !Ó$ˆä
ˆ6�<‰<Ó˜AÔØ×!Ñ! !Ó$ˆä
ˆ6�<‰<Ó˜1ÔØ—‘  F§L¡L°Õ$4°f·l±lÀ2Õ6FÈÏÉÐUWÕHXÐZ`×ZfÑZfÐgiÕZjÓkˆà€Mr   c                ó\   € V ^8„  d   QhR\         P                  R\        R\        R\        /# )r   r$   r   Úforce_contiguousr   )r   r   r   r   )r   s   "r   r   r   Ó   s4   € ÷ Lñ LœEŸL™Lð L´4ð LÔSWð LÔdgñ Lr   c                óŠ  € \        V \        P                  4      '       g   \        R\	        V 4       24      h\        V P                  4      ^8”  g   \        V P                  4      ^8  d   \        R4      hV P                  pV P                  4       P                  4       pVP                  \        P                  8X  d   VP                  4       p\        V4      ^8X  d   M¼\        V4      ^8X  d4   V^ ,          ^8X  d   VP                  ^ 4      MVP                  ^^^ 4      pMy\        V4      ^8X  d\   VP                  ^ ^^^4      pV^ ,          ^8X  d   V'       g   VP                  ^ 4      pV^,          ^8X  d   VP                  R4      pM\        RV 24      hV'       d   VP                  4       pVP!                  4       # )aì  Convert a channels-first image tensor to a channels-last NumPy array for display.

``array = tensor_to_image(tensor)`` takes an ``(H, W)``, ``(C, H, W)`` or ``(B, C, H, W)`` tensor and returns an
``(H, W, C)`` or ``(B, H, W, C)`` NumPy array, detached from autograd and on the CPU. A single channel is dropped,
and so is a batch of one unless ``keepdim=True``, so one 1-, 3- or 4-channel image goes straight to
``matplotlib``'s ``imshow``.

Convention:
    - The array shares memory with a CPU tensor whose dtype NumPy supports, and keeps its dtype.
    - A tensor on another device is copied, ``bfloat16`` becomes a ``float32`` copy, and a dtype NumPy cannot
      represent, such as ``float8_e4m3fn``, raises ``TypeError``.
    - ``force_contiguous=True`` copies a result that is not contiguous, such as the channels-last view of a
      contiguous tensor with more than one channel.

Args:
    tensor: image of the form ``(H, W)``, ``(C, H, W)`` or
        ``(B, C, H, W)``.
    keepdim: If ``True``, keep the batch axis of a ``(1, C, H, W)`` input.
    force_contiguous: If ``True``, call ``contiguous`` on the result before converting it to NumPy.

Returns:
    image of the form ``(H, W)``, ``(H, W, C)``, ``(B, H, W)`` or ``(B, H, W, C)``.

Raises:
    TypeError: if ``tensor`` is not a ``torch.Tensor``.
    ValueError: if ``tensor`` is not two, three or four dimensional.

See Also:
    - :func:`image_to_tensor`: the other direction, from a channels-last array.
    - :meth:`Image.to_numpy`: returns the data of an :class:`Image` in its stored layout, without moving the
      channels.

Example:
    >>> img = torch.ones(1, 3, 3)
    >>> tensor_to_image(img).shape
    (3, 3)

    >>> img = torch.ones(3, 4, 4)
    >>> tensor_to_image(img).shape
    (4, 4, 3)

r=   z:Input size must be a two, three or four dimensional tensorz!Cannot process tensor with shape r>   )r   r   r   r   r   r   r   r   ÚcpuÚdetachÚdtypeÚbfloat16ÚfloatÚsqueezer"   Ú
contiguousÚnumpy)r$   r   rJ   r#   r   s   &&&  r   Útensor_to_imagerT   Ó   sd  € ôV �fœeŸl™l×+Ò+ÜÐ@ÄÀfÃÀÐOÓPÐPä
ˆ6�<‰<Ó˜1Ô¤ F§L¡LÓ 1°AÔ 5ÜÐUÓVÐVà—,‘,€KØ�J‰J‹L×ÑÓ!€EØ‡{�{”e—n‘nÔ$Ø—‘“ˆä
ˆ;Ó˜1ÔàÜ	ˆ[Ó	˜QÔ	ð %0°¥N°aÔ$7�—‘˜aÔ ¸U¿]¹]È1ÈaÐQRÓ=S‰Ü	ˆ[Ó	˜QÔ	à—‘˜a  A qÓ)ˆØ�q�>˜QÔ§wØ—M‘M !Ó$ˆEØ�q�>˜QÔØ—M‘M "Ó%ˆEøäÐ<¸[¸MÐJÓKÐK÷ Ø× Ñ Ó"ˆà�;‰;‹=Ðr   c                   óX   a a€ ] tR tRt oRtRV3R lV 3R llltV3R lR ltRtVtV ;t	# )	ÚImageToTensori"  ak  Convert a NumPy image to a channels-first tensor (module form, batched by default).

``to_tensor = ImageToTensor(keepdim)`` stores ``keepdim``, and ``tensor = to_tensor(array)`` is
:func:`image_to_tensor` with it. Unlike the function, ``keepdim`` defaults to ``False``, so an ``(H, W, C)`` array
becomes ``(1, C, H, W)``.

Args:
    keepdim: If ``False``, a 2-D or 3-D input gets a leading batch axis, ``(1, C, H, W)``. A 4-D input is
        always ``(B, C, H, W)``.

See Also:
    - :func:`image_to_tensor`: the function form.

Example:
    >>> ImageToTensor()(np.ones((4, 5, 3))).shape
    torch.Size([1, 3, 4, 5])

c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   r   r   N)r   )r   Ú__classdict__s   "€r   r   ÚImageToTensor.__annotate__6  s   ø€ ÷ ñ ¡ð °ñ r   c                ó0   <€ \         SV `  4        Wn        R # r*   )ÚsuperÚ__init__r   )Úselfr   Ú	__class__s   &&€r   r\   ÚImageToTensor.__init__6  s   ø€ Ü‰ÑÔØŽr   c                ó:   <€ V ^8„  d   QhRS[ RS[P                  /# )r   Úxr   )r   r   r   )r   rX   s   "€r   r   rY   :  s   ø€ ÷ 8ñ 8™ð 8¡§¡ñ 8r   c                ó.   € \        WP                  R7      # )a�  Convert a NumPy image array into a PyTorch image tensor.

Args:
    x: Input image array accepted by :func:`image_to_tensor`, of
        layout ``(H, W)``, ``(H, W, C)`` or ``(B, H, W, C)``,
        where :math:`B` is batch size, :math:`H` is height,
        :math:`W` is width, and :math:`C` is channel count.

Returns:
    Tensor returned by :func:`image_to_tensor` with ``keepdim=self.keepdim``.
©r   )r%   r   )r]   ra   s   &&r   ÚforwardÚImageToTensor.forward:  s   € ô ˜q¯,©,Ô7Ð7r   rc   )F)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r\   rd   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r^   rX   s   @@r   rV   rV   "  s#   ù‡ € ñ÷&õ ÷8÷ 8ð 8r   rV   c                ó†   € V ^8„  d   QhR\         P                  R\        \        ,          R\        R\         P                  /# )r   r$   Ún_rowÚpaddingr   )r   r   r   Úint)r   s   "r   r   r   I  s=   € ÷ J1ñ J1”e—l‘lð J1¬8´C­=ð J1Ì#ð J1ÔV[×VbÑVbñ J1r   c                ó   € \        V \        P                  4      '       g   \        R4      hV^ 8  d   \	        R4      hV P
                  w  r4rVVfk   \        ^\        \        P                  ! \        P                  ! V\        P                  R7      4      P                  4       P                  4       4      4      pMV^8  d   \	        R4      hTpW7,           ^,
          V,          pWR,           pWb,           p	\        P                  ! V ^ V^ V34      p
W,          pW³8”  dP   \        P                  ! W³,
          WHV	3V P                   V P"                  R7      p\        P$                  ! W¬3^ R7      p
V
P'                  4       p
V
P)                  WWHV	4      pVP+                  ^^ ^^^4      P'                  4       pVP)                  WAV,          Wy,          4      pW,          V,
          pWy,          V,
          pVRRV1RV13,          # )	aN  Tile a batch of images into one image, row by row, with zero padding between.

``grid = make_grid(tensor, n_row)`` places the ``B`` images of a ``(B, C, H, W)`` tensor ``n_row`` per row, in batch
order, and returns one ``(C, H', W')`` image with ``padding`` zero pixels between neighbors and none around the
border. It does not rescale or convert the images.

Convention:
    - ``n_row`` is the number of columns, as torchvision's ``nrow``. Zero images complete the last row, and
      ``n_row > B`` still gives ``n_row`` columns.
    - The channels are kept, and ``R`` rows of ``n_row`` images with ``p = padding`` give
      ``(C, R * (H + p) - p, n_row * (W + p) - p)``.
    - The grid is a new tensor in the input's dtype and on its device; :math:`B = 0` gives a zero-height grid.
    - :ref:`Files and arrays <image-io-conventions>` compares it with torchvision's ``make_grid``.

Args:
    tensor: A batched tensor of shape (B, C, H, W).
    n_row: Number of images displayed in each row of the grid. If ``None``, :math:`\lceil \sqrt{B} \rceil`.
    padding: The amount of padding to add between images; must be non-negative.

Returns:
    torch.Tensor: The combined image grid.

Raises:
    TypeError: if ``tensor`` is not a ``torch.Tensor``.
    ValueError: if ``tensor`` is not four dimensional, ``n_row`` is not positive or ``padding`` is negative.

See Also:
    - :func:`~kornia.contrib.combine_tensor_patches`: reassembles one image from its own sliding-window patches,
      averaging where they overlap.

Example:
    >>> make_grid(torch.rand(5, 3, 4, 6), n_row=2).shape
    torch.Size([3, 16, 14])

z&Input tensor must be a PyTorch tensor.zpadding must be non-negative.N)rN   zn_row must be positive.)rN   Údevicer/   :NNN)r   r   r   r   r   r   Úmaxrq   Úsqrtr$   Úfloat32ÚceilÚitemÚFÚpadÚzerosrN   rs   ÚcatrR   Úviewr"   )r$   ro   rp   ÚBÚCÚHÚWÚn_colÚpadded_HÚpadded_WÚtensor_paddedÚtotalÚ	pad_tilesÚgridÚcombinedÚ
combined_HÚ
combined_Ws   &&&              r   Ú	make_gridrŒ   I  s­  € ôH �fœeŸl™l×+Ò+ÜÐ@ÓAÐAØ�„{ÜÐ8Ó9Ð9à—‘�J€Aˆ!Ø‚}Ü�A”sœ5Ÿ:š:¤e§l¢l°1¼E¿M¹MÔ&JÓK×PÑPÓR×WÑWÓYÓZÓ[‰Ø	�ŒÜÐ2Ó3Ð3Ø€EØ�Y˜�]˜uÕ$€Eà�{€HØ�{€Hô —E’E˜& 1 g¨q°'Ð":Ó;€Mà�M€EØ„yÜ—K’K ¥¨A¸Ð BÈ&Ï,É,Ð_e×_lÑ_lÔmˆ	ÜŸ	š	 =Ð"<À!ÔDˆð "×,Ñ,Ó.€Mð ×Ñ˜e¨A¸ÓB€Dð �<‰<˜˜1˜a  AÓ&×1Ñ1Ó3€DØ�y‰y˜ HÕ,¨eÕ.>Ó?€Hð Õ! GÕ+€JØÕ! GÕ+€Jà�A�{˜
�{ K Z KÐ/Õ0Ð0r   c                óŒ   € V ^8„  d   QhR\         R\        P                  3,          R\         R\        P                  3,          /# ©r   Úf.r   ©r   r   r   )r   s   "r   r   r   –  s6   € ÷ 4ñ 4¤¨¬e¯l©lÐ):Õ ;ð 4ÄÈÌeÏlÉlÐIZÕ@[ñ 4r   c                ó6   a € \        S 4      R V 3R ll4       pV# )aU  Decorate a ``(B, C, H, W)`` function to accept any number of leading dimensions.

``g = perform_keep_shape_image(f)`` returns ``g(input, *args, **kwargs)``, which calls ``f`` on ``input`` reshaped
to ``(B, C, H, W)`` with the other arguments and gives the result the input's leading dimensions back. Use it as
``@perform_keep_shape_image`` on a function written for batches.

Convention:
    - ``f`` always receives a ``(B, C, H, W)`` tensor: an ``(H, W)`` input becomes ``(1, 1, H, W)``, a
      ``(C, H, W)`` input ``(1, C, H, W)``, and the leading dimensions of a longer input are flattened into ``B``.
      The result keeps ``f``'s own ``C``, ``H`` and ``W``, except that an ``(H, W)`` input gets ``f``'s first
      channel only; ``f`` must keep the batch size.
    - A zero channel, height or width raises ``ValueError`` before ``f`` is called. Zero leading dimensions, such
      as an empty batch, are passed to ``f``, so an empty batch gives an empty output.

Raises:
    TypeError: if ``input`` is not a tensor.
    ValueError: if ``input`` has fewer than two dimensions or a zero channel, height or width.

See Also:
    - :func:`perform_keep_shape_video`: the same for ``(B, C, D, H, W)`` volumes.

Example:
    >>> @perform_keep_shape_image
    ... def double(x):
    ...     return 2 * x
    >>> double(torch.ones(4, 5)).shape
    torch.Size([4, 5])
c                óp   € V ^8„  d   QhR\         P                  R\        R\        R\         P                  /# ©r   ÚinputÚargsÚkwargsr   ©r   r   r   )r   s   "r   r   Ú.perform_keep_shape_image.<locals>.__annotate__µ  ó0   € ÷ ñ œŸ™ð ¬Sð ¼Cð ÄEÇLÁLñ r   c                 óÌ  <€ \        V \        P                  4      '       g   \        R \	        V 4       24      h^ V P
                  RR 9   d   \        R4      hV P
                  p\        V 4      p S! V .VO5/ VB p\        V4      ^8X  d
   V^ ,          p\        V4      ^8X  d
   VR,          p\        V4      ^8”  d(   VP                  ! VRR VP
                  RR ,           !  pV# )ú,Input input type is not a torch.Tensor. Got Nú"Invalid input tensor, it is empty.r?   ©r   r   )
r   r   r   r   r   r   r   rD   r   rB   ©r”   r•   r–   r#   Úoutputr�   s   &*,  €r   Ú_wrapperÚ*perform_keep_shape_image.<locals>._wrapper´  sÔ   ø€ ä˜%¤§¡×.Ò.ÜÐJÌ4ÐPUË;È-ÐXÓYÐYà�—‘˜B˜CÐ Ô ÜÐAÓBÐBà—k‘kˆÜ˜“ˆÙ�5Ð*˜4Ò* 6Ñ*ˆÜˆ{Ó˜qÔ Ø˜A•YˆFäˆ{Ó˜qÔ Ø˜D•\ˆFäˆ{Ó˜aÔØ—^’^ k°#°2Ð&6¸¿¹ÀbÀcÐ9JÕ&JÑLˆFàˆr   r   ©r�   r    s   f r   Úperform_keep_shape_imager£   –  s"   ø€ ô< ˆ1ƒX÷ó ðð* €Or   c                óŒ   € V ^8„  d   QhR\         R\        P                  3,          R\         R\        P                  3,          /# rŽ   r�   )r   s   "r   r   r   Í  s6   € ÷ (ñ (¤¨¬e¯l©lÐ):Õ ;ð (ÄÈÌeÏlÉlÐIZÕ@[ñ (r   c                ó6   a € \        S 4      R V 3R ll4       pV# )a
  Decorate a ``(B, C, D, H, W)`` function to accept any number of leading dimensions.

``g = perform_keep_shape_video(f)`` returns ``g(input, *args, **kwargs)``, which calls ``f`` on ``input`` reshaped
to ``(B, C, D, H, W)`` with the other arguments and gives the result the input's leading dimensions back.

Convention:
    See the Convention block of :func:`perform_keep_shape_image`, with ``f`` receiving ``(B, C, D, H, W)``: a
    ``(D, H, W)`` input becomes ``(1, 1, D, H, W)`` and a ``(C, D, H, W)`` input ``(1, C, D, H, W)``.

Raises:
    TypeError: if ``input`` is not a tensor.
    ValueError: if ``input`` has fewer than three dimensions or a zero channel, depth, height or width.

See Also:
    - :func:`perform_keep_shape_image`: the same for ``(B, C, H, W)`` images.
c                óp   € V ^8„  d   QhR\         P                  R\        R\        R\         P                  /# r“   r—   )r   s   "r   r   Ú.perform_keep_shape_video.<locals>.__annotate__à  r™   r   c                 óÌ  <€ \        V \        P                  4      '       g   \        R \	        V 4       24      h^ V P
                  RR 9   d   \        R4      hV P
                  p\        V 4      p S! V .VO5/ VB p\        V4      ^8X  d
   V^ ,          p\        V4      ^8X  d
   VR,          p\        V4      ^8”  d(   VP                  ! VRR VP
                  RR ,           !  pV# )r›   Nrœ   rG   r�   )
r   r   r   r   r   r   r   rH   r   rB   rž   s   &*,  €r   r    Ú*perform_keep_shape_video.<locals>._wrapperß  sÕ   ø€ ä˜%¤§¡×.Ò.ÜÐJÌ4ÐPUË;È-ÐXÓYÐYà�—‘˜B˜CÐ Ô ÜÐAÓBÐBà—k‘kˆÜ˜%Ó ˆÙ�5Ð*˜4Ò* 6Ñ*ˆÜˆ{Ó˜qÔ Ø˜A•YˆFäˆ{Ó˜qÔ Ø˜D•\ˆFäˆ{Ó˜aÔØ—^’^ k°#°2Ð&6¸¿¹ÀbÀcÐ9JÕ&JÑLˆFàˆr   r   r¢   s   f r   Úperform_keep_shape_videorª   Í  s"   ø€ ô$ ˆ1ƒX÷ó ðð* €Or   )T)FF)Nr   )Ú	functoolsr   Útypingr   r   r   r   rS   r   r   r	   Útorch.nnr
   ry   r%   r8   rD   rH   rT   ÚModulerV   rŒ   r£   rª   © r   r   Ú<module>r°      s]   ðõ& ß 0Ó 0ã Û Ý Ý $÷E:õP4<õnõ8÷8Lô^$8�B—I‘Iô $8÷NJ1õZ4÷n(r   