+
     åûj	Ð  ã                  ó6  a € 0 t $ R t^ RIHt ^ RIt^ RIHt ^ RIHtH	t	H
t
HtHtHtHtHtHtHt ^ RIt^ RIHtHtHt ^ RIHt ^ RIHtHtHtHtHtHtHt . R@Ot R R	 lt!]!! 4       s"R
]#R&   ]! ^^4      t$]'       d   ]]%]
. ]%3,          3,          t&M]%t&R R lt'R R lt(R R lt)R R lt*RAR R llt+RAR R llt,R R lt-RBR R llt.R R lt/]! R]0R7      t1R  R! lt2RAR" R# llt3RAR$ R% llt4RCR& R' llt5RCR( R) llt6RAR* R+ llt7RCR, R- llt8RDR. R/ llt9RAR0 R1 llt:RAR2 R3 llt;RAR4 R5 llt<RAR6 R7 llt=]P|                  ]P~                  ]P€                  ]P‚                  ]P„                  ]P†                  /tDRER8 R9 lltERCR: R; lltFRCR< R= lltGR> R? ltHR# )Faî  Validate inputs: check conditions, shapes, sizes, types, devices and image layouts.

Every ``KORNIA_CHECK*`` function returns ``True`` when its check passes, and, outside TorchScript, also without
checking while the checks are disabled. On failure it raises an error from ``kornia.core.exceptions``, or returns
``False`` with ``raises=False``. A ``msg`` argument, where a check takes one, is a string or a function without
arguments that returns it, called only on failure; see :func:`KORNIA_CHECK`. To turn the checks off, see
:func:`disable_checks`.

Which function to use:

- Any boolean condition: :func:`KORNIA_CHECK`, which raises the plain :exc:`~kornia.core.exceptions.BaseError`.
- Shape: against a pattern of named and fixed dimensions such as ``["B", "3", "H", "W"]``, :func:`KORNIA_CHECK_SHAPE`;
  against sizes computed at run time, :func:`KORNIA_CHECK_SIZES`; one dimension against another tensor's,
  :func:`KORNIA_CHECK_SAME_SIZE`; every dimension against another tensor's, :func:`KORNIA_CHECK_SAME_SHAPE`; a distance
  matrix against its descriptors, :func:`KORNIA_CHECK_DM_DESC`; the shape of local affine frames,
  :func:`~kornia.feature.KORNIA_CHECK_LAF`.
- Image layout: color, :func:`KORNIA_CHECK_IS_COLOR`; gray, :func:`KORNIA_CHECK_IS_GRAY`; either,
  :func:`KORNIA_CHECK_IS_COLOR_OR_GRAY`; either, with values in :math:`[0, 1]`, or up to ``2 ** bits - 1`` for integers,
  :func:`KORNIA_CHECK_IS_IMAGE`.
- Type: a tensor, :func:`KORNIA_CHECK_IS_TENSOR`; any type, :func:`KORNIA_CHECK_TYPE`; a list of tensors,
  :func:`KORNIA_CHECK_IS_LIST_OF_TENSOR`; narrow an optional value for a static type checker, without checking it,
  :func:`KORNIA_UNWRAP`.
- Device: two tensors, :func:`KORNIA_CHECK_SAME_DEVICE`; a list of tensors, :func:`KORNIA_CHECK_SAME_DEVICES`.
- Turn the checks off and on: :func:`disable_checks`, :func:`enable_checks`; read the state: :func:`are_checks_enabled`.
- The errors, re-exported from ``kornia.core.exceptions``: :exc:`~kornia.core.exceptions.BaseError`,
  :exc:`~kornia.core.exceptions.ShapeError`, :exc:`~kornia.core.exceptions.TypeCheckError`,
  :exc:`~kornia.core.exceptions.ValueCheckError`, :exc:`~kornia.core.exceptions.AsyncCheckError`,
  :exc:`~kornia.core.exceptions.DeviceError`, :exc:`~kornia.core.exceptions.ImageError`.
)ÚannotationsN)Ú	UnionType)
ÚTYPE_CHECKINGÚAnyÚCallableÚOptionalÚSequenceÚTypeVarÚUnionÚcastÚget_argsÚ
get_origin)Úfloat16Úfloat32Úfloat64)Útorch_version_ge)ÚAsyncCheckErrorÚ	BaseErrorÚDeviceErrorÚ
ImageErrorÚ
ShapeErrorÚTypeCheckErrorÚValueCheckErrorc               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚbool© )Úformats   "ÚMC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\core\check.pyÚ__annotate__r!   c   s   € ÷ ñ ˜tñ ó    c                 ób   € \         P                  ! RR4      p V e   V P                  4       R9   # R# )a$  Determine if checks should be enabled.

Returns:
    True if checks should be enabled, False otherwise.

Checks are enabled by default in debug mode (normal Python execution).
Checks are disabled when:
- Running with `python -O` (optimized mode)
- Environment variable KORNIA_CHECKS=0 is set
ÚKORNIA_CHECKSNT)Ú1ÚtrueÚyesÚon)ÚosÚgetenvÚlower)Úenv_vars    r    Ú_should_enable_checksr-   c   s/   € ô �iŠi˜¨Ó.€GØÒà�}‰}‹Ð"<Ñ<Ð<ár"   r   Ú_KORNIA_CHECKS_ENABLEDc               ó    € V ^8„  d   QhRRRR/# )r   ÚmsgúOptional[CheckMessage]r   zOptional[str]r   )r   s   "r    r!   r!   …   s   € ÷ ñ Ð,ð °ñ r"   c                ó~   € \         P                  P                  4       '       g   \        V 4      '       d   V ! 4       # V # )zKReturn the message of a failed check, calling it first if it is a function.)ÚtorchÚjitÚis_scriptingÚcallable)r0   s   &r    Ú_resolve_msgr7   …   s*   € ä�9‰9×!Ñ!×#Ò#Ü�C�=Š=Ù“5ˆLØ€Jr"   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r    r!   r!   �   s   € ÷ "ñ "˜Dñ "r"   c                 ó   € \         # )a�  Report whether kornia's input checks currently run.

``enabled = are_checks_enabled()`` returns the flag that :func:`disable_checks` and :func:`enable_checks` set. At
import, the ``KORNIA_CHECKS`` environment variable sets it: ``1``, ``true``, ``yes`` or ``on``, in any case, enable
the checks, and any other value, the empty string included, disables them. Without the variable, checks are enabled,
except under ``python -O``.

Returns:
    ``True`` if checks are enabled, ``False`` otherwise.

See Also:
    - :func:`disable_checks`: turns the checks off.
    - :func:`enable_checks`: turns them back on.

Example:
    >>> are_checks_enabled()
    True
©r.   r   r"   r    Úare_checks_enabledr;   �   s
   € ô& "Ð!r"   c               ó   € V ^8„  d   QhRR/# ©r   r   ÚNoner   )r   s   "r    r!   r!   £   s   € ÷ #ñ #˜ñ #r"   c                 ó
   € Rs R# )a^  Turn off kornia's input checks until enable_checks turns them back on.

After ``disable_checks()``, every ``KORNIA_CHECK*`` function returns ``True`` without checking, in eager code and
under ``torch.compile``. The value checks behind :exc:`~kornia.core.exceptions.AsyncCheckError` are skipped too,
except the input-range checks of :func:`~kornia.enhance.equalize` and :func:`~kornia.enhance.equalize_clahe`, which
keep a lookup index in bounds. A call compiled with ``torch.jit.script`` ignores the flag and runs the
``KORNIA_CHECK*`` functions regardless; on CUDA it skips the value checks behind
:exc:`~kornia.core.exceptions.AsyncCheckError`, enabled or not.

See Also:
    - :func:`enable_checks`: turns the checks back on.
    - :func:`are_checks_enabled`: reads the current state.

Example:
    >>> disable_checks()
    >>> are_checks_enabled()
    False
FNr:   r   r"   r    Údisable_checksr@   £   s
   € ð( #Òr"   c               ó   € V ^8„  d   QhRR/# r=   r   )r   s   "r    r!   r!   º   s   € ÷ "ñ "�tñ "r"   c                 ó
   € Rs R# )aC  Turn kornia's input checks back on, also after KORNIA_CHECKS=0 or python -O.

After ``enable_checks()``, every check runs again.

See Also:
    - :func:`disable_checks`: turns the checks off.
    - :func:`are_checks_enabled`: reads the current state.

Example:
    >>> enable_checks()
    >>> are_checks_enabled()
    True
TNr:   r   r"   r    Úenable_checksrC   º   s
   € ð "Òr"   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R/# )
r   Úxútorch.TensorÚshapez	list[str]r0   r1   Úraisesr   r   r   )r   s   "r    r!   r!   Ï   s;   € ÷ añ aØðaØ%ðaØ,BðaØSWðaà	ñar"   c                ó¨  € \         P                  P                  4       '       g   \        '       g   R# ^ p\	        V4      ^ 8”  dW   RV^ ,          8X  dI   VR,          p\        \	        V P                  4      \	        V4      ,
          ^ 4      pV P                  VR pMQ\	        V4      ^ 8”  d4   RVR,          8X  d&   VRR pV P                  R\	        V4      ^,
           pMTpV P                  p\	        V4      \	        V4      8w  d�   V'       dw   \        V4      p\	        V4      p\	        V4      pRV RV R2p	V	RV R	2,          p	\        V P                  4      p
V	R
V
 2,          p	Ve   V	RV 2,          p	\        V	V
VR7      hR# \        \	        V4      4       Fµ  pW[,          pVP                  4       '       g   K#  \        V4      pWk,          V8w  g   K=  V'       dp   \        V4      pRW´,            RV RWk,           R2p	V	RV R	2,          p	\        V P                  4      p
V	R
V
 2,          p	Ve   V	RV 2,          p	\        V	V
VR7      h R# 	  R# )ai  Check a tensor's shape against a pattern of named and fixed dimensions.

``KORNIA_CHECK_SHAPE(x, ["B", "3", "H", "W"])`` returns ``True`` when ``x`` has one dimension per entry and every
entry made of digits equals the size of its dimension. Any other entry, such as ``"B"``, matches any size, and equal
names are not compared with each other: ``["N", "N"]`` accepts a ``(2, 3)`` tensor. A ``"*"`` as the first entry
matches any number of leading dimensions; otherwise a ``"*"`` as the last entry matches any number of trailing ones.
It does not check that ``x`` is a tensor.

Args:
    x: the tensor to evaluate.
    shape: the expected pattern, one string per dimension, with a ``"*"`` allowed first or last: ``["*"]`` accepts
        any shape and ``[]`` only a 0-dimensional tensor.
    msg: message to append to the error, or a function that returns it; see :func:`KORNIA_CHECK`.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    ShapeError: if ``x`` does not match ``shape`` and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_SIZES`: takes integer sizes computed at run time, ``None`` for any size.
    - :func:`KORNIA_CHECK_SAME_SHAPE`: compares the whole shape with another tensor's.
    - :func:`~kornia.feature.KORNIA_CHECK_LAF`: this check with the fixed pattern ``["B", "N", "2", "3"]``.

Example:
    >>> x = torch.rand(2, 3, 4, 4)
    >>> KORNIA_CHECK_SHAPE(x, ["B", "C", "H", "W"])
    True

    >>> x = torch.rand(2, 3, 4, 4)
    >>> KORNIA_CHECK_SHAPE(x, ["2", "3", "H", "W"])
    True

TÚ*:é   NNNz#Shape dimension mismatch: expected z dimensions, got ú.
ú  Expected shape: Ú
ú  Actual shape: ú
  ©Úactual_shapeÚexpected_shapeFzShape mismatch at dimension ú: expected ú, got éÿÿÿÿ)r3   r4   r5   r.   ÚlenÚmaxrG   r7   Úlistr   ÚrangeÚ	isnumericÚint)rE   rG   r0   rH   Údimension_offsetÚshape_to_checkÚx_shape_to_checkÚexpected_dimsÚactual_dimsÚ	error_msgÚx_shape_listÚiÚdim_Údims   &&&&          r    ÚKORNIA_CHECK_SHAPErg   Ï   sU  € ôN �9‰9×!Ñ!×#Ò#ß%Ó%ÙàÐÜ
ˆ5ƒz�A„~˜#  q¥œ/Ø˜r�ˆÜœs 1§7¡7›|¬c°.Ó.AÕAÀ1ÓEÐØŸ7™7Ð#3Ð#4Ð5ÑÜ	ˆU‹�aŒ˜C 5¨¥9Ô,Ø˜s ˜ˆØŸ7™7Ð#3¤S¨£Z°!¥^Ð4ÑàˆØŸ7™7Ðä
ÐÓ¤ NÓ 3Ô3ßÜ˜sÓ#ˆCÜ Ó/ˆMÜÐ.Ó/ˆKØ=¸m¸_ÐL]Ð^iÐ]jÐjmÐnˆIØÐ-¨e¨W°BÐ7Õ7ˆIÜ §¡›=ˆLØÐ+¨L¨>Ð:Õ:ˆIØŠØ˜t C 5˜\Õ)�	ÜØØ)Ø$ôð ñ
 ä”3Ð'Ó(Ö)ˆð #Õ%ˆØ�~‰~×ÒÙÜ�$‹iˆØÕ #Ö%ßÜ" 3Ó'�à2°1Õ3GÐ2HÈÐTWÐSXÐX^Ð_oÕ_rÐ^sÐsvÐwð ð Ð1°%°¸Ð;Õ;�	Ü# A§G¡G›}�ØÐ/°¨~Ð>Õ>�	Ø’?Ø 4¨ u Õ-�IÜ ØØ!-Ø#(ôð ò
 ñ/ *ñ0 r"   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Ú	conditionr   r0   r1   rH   r   r   )r   s   "r    r!   r!   3  s*   € ÷ 0ñ 0˜Dð 0Ð'=ð 0Èdð 0Ð^bñ 0r"   c                óÊ   € \         P                  P                  4       '       g   \        '       g   R# V '       g)   V'       d   \	        V4      pVf   RMTp\        V4      hR# R# )aÕ  Check an arbitrary boolean condition, raising the base kornia error when it is false.

``KORNIA_CHECK(condition, msg)`` returns ``True`` when ``condition`` is true. Otherwise it raises
:exc:`~kornia.core.exceptions.BaseError` with ``msg`` as the message (``"Validation condition failed"`` without
one). :exc:`~kornia.core.exceptions.BaseError` is neither a :exc:`ValueError` nor a :exc:`TypeError`; for a shape, a
size, a type or a device, use the dedicated check, whose error is one of them.

Args:
    condition: the condition to evaluate.
    msg: message to show in the exception, or a function without arguments that returns it. A function is called
        only when the check fails. Python builds an f-string argument on every call, and under a dynamic-shape
        ``torch.compile`` formatting a tensor size or an ``int`` argument specializes it, so each new value would
        compile a new graph. A check on sizes therefore compares them with :func:`KORNIA_CHECK_SAME_SIZE`,
        :func:`KORNIA_CHECK_SIZES` or :func:`KORNIA_CHECK_SHAPE`, which format only on failure, and any other
        message that formats such a value is a function, as in ``lambda: f"got {n}"``. TorchScript takes only a
        string.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    BaseError: if the condition is not met and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_SHAPE`: checks a shape pattern and raises :exc:`~kornia.core.exceptions.ShapeError`.
    - :func:`KORNIA_CHECK_SIZES`: checks sizes computed at run time without specializing them.
    - :func:`KORNIA_CHECK_TYPE`: checks a type and raises :exc:`~kornia.core.exceptions.TypeCheckError`.

Example:
    >>> x = torch.rand(2, 3, 3)
    >>> KORNIA_CHECK(x.shape[-2:] == (3, 3), "Invalid homography")
    True
    >>> KORNIA_CHECK(x.shape[0] == 2, lambda: f"Expected a batch of 2, got {x.shape[0]}")
    True

TzValidation condition failedF)r3   r4   r5   r.   r7   r   )ri   r0   rH   rb   s   &&& r    ÚKORNIA_CHECKrk   3  sN   € ôL �9‰9×!Ñ!×#Ò#ß%Ó%ÙçßÜ˜sÓ#ˆCØ9<ºÑ5È#ˆIÜ˜IÓ&Ð&ÙÙr"   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r    r!   r!   f  s   € ÷ oñ o˜ñ or"   c                 óÒ   € \         P                  P                  P                  4       p V RJ;'       d5    \        ;QJ d    R V  4       F  '       g   K   R# 	  R# ! R V  4       4      # )zCWhether a ``torch.vmap`` level is on the functorch transform stack.Nc              3  óž   "  € T FC  qP                  4       \        P                  P                  P                  P
                  8H  x € KE  	  R # 5i©N)Úkeyr3   Ú_CÚ
_functorchÚTransformTypeÚVmap)Ú.0Úlevels   & r    Ú	<genexpr>Ú"_vmap_is_active.<locals>.<genexpr>i  s2   é € Ð$nÑhmÐ_d§Y¡Y£[´E·H±H×4GÑ4G×4UÑ4U×4ZÑ4ZÖ%ZÓhmùs   ‚AATF)r3   rq   rr   Úget_interpreter_stackÚany)Ústacks    r    Ú_vmap_is_activer|   f  sR   € ä�H‰H×Ñ×5Ñ5Ó7€EØ˜Ð×nÐn§£Ñ$nÑhmÓ$n§¤Ðn¢Ðn Ñ$nÑhmÓ$nÓ!nÐnr"   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   ri   rF   r0   ÚstrÚguardr   r   r>   r   )r   s   "r    r!   r!   l  s(   € ÷ 8,ñ 8,˜Lð 8,¨sð 8,¸4ð 8,ÈDñ 8,r"   c                óT  € V P                   P                  R9  p\        P                  P	                  4       '       Eg.   V'       g   \
        '       g   R# \        P                  P                  4       '       dB   \        P                  P                  4       '       d   V'       g   R# M\        4       '       d   R# V P                   P                  pVR9   ;'       g    VR8H  ;'       d    \        p\        P                  P                  4       '       g%   \        P                  P                  4       '       d!   V'       d   \        P                  ! W4       R# V'       * ;'       g    VR8H  pV'       d   \        V 4      '       g   \        V4      hR# \        P                  ! W4       R# )aÔ	  Check a boolean tensor ``condition`` where it lives, without reading it back from an accelerator.

On CUDA, and on MPS from torch 2.13, the check is ``torch._assert_async``: the call returns at once, and a false
``condition`` raises :exc:`RuntimeError` by the next synchronization, possibly earlier: on CUDA often at the next
kernel launch, still inside the calling function. On CUDA it is a device-side assert, after which the context
cannot be used. Reading the condition on the host instead would wait for every queued kernel.

On the CPU, on MPS before torch 2.13, which has no assert kernel, and on any other device, the condition is read on
the host and a false one raises :exc:`~kornia.core.exceptions.AsyncCheckError` during the call. A meta tensor has
no value to check.

Under ``torch.compile`` and ``torch.export`` the check is ``torch._assert_async`` on every device that has the
kernel, so it stays in the graph and raises :exc:`RuntimeError`; Inductor keeps it from torch 2.9 and compiles it
to nothing before. On a device without the kernel nothing is checked there. ``torch.jit.trace`` runs the assert on
the traced values but drops it from the graph it records, and TorchScript drops it too, so a scripted call checks
on the host only. It does so on every device but CUDA, since TorchScript cannot read whether MPS has the kernel.
A scripted CUDA call is not checked. The check is skipped when checks are disabled with :func:`disable_checks`,
with ``python -O`` or with ``KORNIA_CHECKS=0``, unless ``guard`` is set. It is also skipped under ``torch.vmap``,
which has no batching rule for the assert. Eager calls keep it under the other functorch transforms, such as
``torch.func.grad``; a compiled call skips it under all of them, unless ``guard`` is set, since Dynamo cannot
inspect the transform stack.

Args:
    condition: a boolean tensor with one element, usually ``(...).all()``.
    msg: the message of the error. It is a string, since the device assert carries it unformatted.
    guard: run the check even when checks are disabled, and under a compiled functorch transform. Set it where the
        check keeps a later index in bounds: on the CPU a compiled ``gather`` or ``scatter`` with an index out of
        range terminates the process. A compiled ``torch.vmap`` with ``fullgraph=True`` then fails to trace, as the
        assert has no batching rule, so set it only in code that cannot run under ``vmap`` anyway, such as the
        in-place histograms of the ``equalize`` lookups.
NÚcpuÚmps)ÚcudaÚmeta)r�   rƒ   r„   )ÚdeviceÚtyper3   r4   r5   r.   rq   Ú _are_functorch_transforms_activeÚcompilerÚis_compilingr|   Ú_MPS_HAS_ASSERT_ASYNCÚ
is_tracingÚ_assert_asyncr   r   )ri   r0   r   Úon_hostÚkindÚ
has_kernels   &&&   r    Ú_check_asyncr�   l  s#  € ðB ×Ñ×#Ñ#Ð+;Ñ;€GÜ�9‰9×!Ñ!×#Ó#ß×/Ó/ÙÜ�8‰8×4Ñ4×6Ò6Ü�~‰~×*Ñ*×,Ò,÷ Ùð ä ×"Ò"ÙØ×Ñ×$Ñ$ˆØÐ4Ñ4×aÐa¸À¹×9`Ð9`ÔK`ˆ
Ü�>‰>×&Ñ&×(Ò(¬E¯I©I×,@Ñ,@×,BÒ,BßÜ×#Ò# IÔ3ÙØ ”.×1Ð1 D¨E¡MˆßÜ�I�ŠÜ! #Ó&Ð&ñ ô 	×Ò˜IÖ+r"   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Ú	maybe_objr   Útypr   r   )r   s   "r    r!   r!   §  s!   € ÷  ñ  ˜Sð   sð  ¨sñ  r"   c                ó   € \        W4      # )ag  Narrow an optional value to a type for static type checkers, without checking it.

``obj = KORNIA_UNWRAP(maybe_obj, typ)`` returns ``maybe_obj`` unchanged: it is :func:`typing.cast`, so ``None`` and
a value of another type pass through, whether checks are enabled or not. To check the type at run time, use
:func:`KORNIA_CHECK_TYPE`. TorchScript cannot compile it.

Args:
    maybe_obj: the object to unwrap.
    typ: the type that static type checkers assume for the result.

Returns:
    ``maybe_obj``, unchanged.

See Also:
    - :func:`KORNIA_CHECK_TYPE`: raises :exc:`~kornia.core.exceptions.TypeCheckError`.

)r   )r’   r“   s   &&r    ÚKORNIA_UNWRAPr•   §  s   € ô& �ÓÐr"   Ú_T)Úboundc               ó    € V ^8„  d   QhRRRR/# )r   r“   r   r   r~   r   )r   s   "r    r!   r!   À  s   € ÷ /ñ /�Cð /˜Cñ /r"   c                ó¤   € \        V 4      \        \        39   d"   RP                  R \	        V 4       4       4      # \        V R\        V 4      4      # )zPName a type for an error message, spelling a union of any kind as ``int | str``.ú | c              3  óX   "  € T F   q\        R 4      J d   RM
\        V4      x € K"  	  R # 5i)Nr>   )r†   Ú
_type_name)ru   Úargs   & r    rw   Ú_type_name.<locals>.<genexpr>Å  s$   é € ÐdÑVcÈs¬4°«:Ó$5™&¼:Àc»?ÔJÓVcùs   ‚(*Ú__name__)r   r
   r   Újoinr   ÚgetattrÚrepr)r“   s   &r    rœ   rœ   À  sD   € ô �#ƒœ5¤)Ð,Ô,Ø�z‰zÑdÔV^Ð_bÔVcÓdÓdÐdÜ�3˜
¤D¨£IÓ.Ð.r"   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R/# )
r   rE   r   r“   z_T | tuple[_T, ...]r0   r1   rH   r   r   r   )r   s   "r    r!   r!   É  s4   € ÷ 7ñ 7Ø
ð7Ø$ð7Ø+Að7ØRVð7à	ñ7r"   c                ó2  € \         P                  P                  4       '       g   \        '       g   R# \	        W4      '       gÔ   V'       dÊ   \        V4      p\         P                  P                  4       '       d   RpVe   VRV 2,          p\        V4      h\	        V\        4      '       d   RP                  R V 4       4      M
\        V4      p\        \        V 4      4      pRV RV R2pVe   VRV 2,          p\        V\        V 4      VR	7      hR
# R# )aL  Check that a value is an instance of a type, a tuple of types or a union.

``KORNIA_CHECK_TYPE(x, typ)`` returns ``True`` when ``isinstance(x, typ)``, with ``typ`` a class, a tuple of classes
or a union such as ``int | str``; as in :func:`isinstance`, ``True`` passes for ``int``. On failure it raises
:exc:`~kornia.core.exceptions.TypeCheckError`. TorchScript cannot compile it.

Args:
    x: any input variable.
    typ: the expected type, a tuple of types or a union.
    msg: message to show in the exception, or a function that returns it; see :func:`KORNIA_CHECK`.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    TypeCheckError: if ``x`` is not an instance of ``typ`` and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_IS_TENSOR`: checks for a tensor, and TorchScript compiles it.
    - :func:`KORNIA_CHECK_IS_LIST_OF_TENSOR`: checks a list and the type of each of its elements.

Example:
    >>> KORNIA_CHECK_TYPE("foo", str, "Invalid string")
    True

TzType mismatch.rP   rš   c              3  ó8   "  € T F  p\        V4      x € K  	  R # 5iro   )rœ   )ru   Úts   & r    rw   Ú$KORNIA_CHECK_TYPE.<locals>.<genexpr>õ  s   é € Ð*FÁ#¸Q¬:°a¯=¨=Ã#ùs   ‚zType mismatch: expected rU   Ú.©Úactual_typeÚexpected_typeF)r3   r4   r5   r.   Ú
isinstancer7   r   Útupler    rœ   r~   r†   )rE   r“   r0   rH   rb   Úexpected_type_strÚ	type_names   &&&&   r    ÚKORNIA_CHECK_TYPEr°   É  s÷   € ô< �9‰9×!Ñ!×#Ò#ß%Ó%Ùä�a×ÒßÜ˜sÓ#ˆCä�y‰y×%Ñ%×'Ò'Ø,�	Ø’?Ø 4¨ u Õ-�IÜ$ YÓ/Ð/äJTÐUXÔZ_×J`ÒJ` §
¡
Ñ*FÁ#Ó*FÔ FÔfpÐqtÓfuÐÜœD ›G›ˆIØ2Ð3DÐ2EÀVÈIÈ;ÐVWÐXˆIØŠØ˜t C 5˜\Õ)�	Ü ØÜ  ›GØ!ôð ñ
 Ùr"   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   rE   r   r0   r1   rH   r   r   r   )r   s   "r    r!   r!     s*   € ÷ 4ñ 4˜cð 4Ð(>ð 4Ètð 4Ð_cñ 4r"   c                óô  € \         P                  P                  4       '       g   \        '       g   R# \	        V \         P
                  4      '       g¦   V'       dœ   \        V4      p\         P                  P                  4       '       d   RpVe   VRV 2,          p\        V4      h\        \        V 4      4      pRV R2pVe   VRV 2,          p\        V\        V 4      \         P
                  R7      hR# R# )a»  Check that a value is a torch.Tensor, a subclass such as a Parameter included.

``KORNIA_CHECK_IS_TENSOR(x)`` returns ``True`` when ``isinstance(x, torch.Tensor)``, so a ``torch.nn.Parameter``
passes and a NumPy array fails. On failure it raises :exc:`~kornia.core.exceptions.TypeCheckError`.

Args:
    x: any input variable.
    msg: message to show in the exception, or a function that returns it; see :func:`KORNIA_CHECK`.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    TypeCheckError: if ``x`` is not a tensor and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_TYPE`: checks against any type, tuple of types or union.
    - :func:`KORNIA_CHECK_IS_LIST_OF_TENSOR`: checks a list whose elements are tensors.

Example:
    >>> x = torch.rand(2, 3, 3)
    >>> KORNIA_CHECK_IS_TENSOR(x, "Invalid tensor")
    True

TzType mismatch: expected Tensor.rP   z$Type mismatch: expected Tensor, got r¨   r©   F)
r3   r4   r5   r.   r¬   ÚTensorr7   r   r~   r†   )rE   r0   rH   rb   r¯   s   &&&  r    ÚKORNIA_CHECK_IS_TENSORr´     sÎ   € ô6 �9‰9×!Ñ!×#Ò#ß%Ó%Ùä�aœŸ™×&Ò&ßÜ˜sÓ#ˆCä�y‰y×%Ñ%×'Ò'Ø=�	Ø’?Ø 4¨ u Õ-�IÜ$ YÓ/Ð/ô œD ›G›ˆIØ>¸y¸kÈÐKˆIØŠØ˜t C 5˜\Õ)�	Ü ØÜ  ›GÜ#Ÿl™lôð ñ
 Ùr"   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rE   zOptional[Sequence[Any]]rH   r   r   r   )r   s   "r    r!   r!   :  s#   € ÷ /ñ /Ð&=ð /Àtð /ÐW[ñ /r"   c                ón  € \         P                  P                  4       '       g   \        '       g   R# \	        V \
        4      ;'       d5    \        ;QJ d    R V  4       F  '       d   K   RM	  RM! R V  4       4      pV'       g¯   V'       d¥   \        V 4      P                  p\	        V \
        4      '       dD   \        R \        V 4       4       4      pVRV R\        W,          4      P                   2,          pRV R2p\        V\        V 4      \
        \         P                  ,          R	7      hR# R# )
aÀ  Check that a value is a Python list whose elements are all tensors.

``KORNIA_CHECK_IS_LIST_OF_TENSOR(x)`` returns ``True`` for a ``list`` of tensors, the empty list included. A tuple,
``None`` or a list with an element that is not a tensor raises :exc:`~kornia.core.exceptions.TypeCheckError`.
TorchScript cannot compile it.

Args:
    x: any sequence of objects.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    TypeCheckError: if ``x`` is not a list of tensors and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_SAME_DEVICES`: also requires a non-empty list, and that its tensors share a device.
    - :func:`KORNIA_CHECK_IS_TENSOR`: checks a single value.

Example:
    >>> x = torch.rand(2, 3, 3)
    >>> KORNIA_CHECK_IS_LIST_OF_TENSOR(x, raises=False)
    False
    >>> KORNIA_CHECK_IS_LIST_OF_TENSOR([x])
    True

Tc              3  óV   "  € T F  p\        V\        P                  4      x € K!  	  R # 5iro   ©r¬   r3   r³   )ru   Úds   & r    rw   Ú1KORNIA_CHECK_IS_LIST_OF_TENSOR.<locals>.<genexpr>[  s    é € Ð-UÑSTÈa¬j¸¼E¿L¹L×.IÐ.IÓSTùó   ‚')Fc              3  ón   "  € T F+  w  r\        V\        P                  4      '       d   K'  Vx € K-  	  R # 5iro   r¸   )ru   rd   r¹   s   &  r    rw   rº   `  s!   é € Ð[©<¡4 1¼zÈ!ÌUÏ\É\×?ZŸQšQ«<ùs   ‚$5«
5z
; element z is z*Type mismatch: expected list[Tensor], got r¨   r©   )r3   r4   r5   r.   r¬   rY   Úallr†   rŸ   ÚnextÚ	enumerater   r³   )rE   rH   Úare_tensorsÚgotÚindexrb   s   &&    r    ÚKORNIA_CHECK_IS_LIST_OF_TENSORrÃ   :  sä   € ô: �9‰9×!Ñ!×#Ò#ß%Ó%Ùä˜Q¤Ó%×UÐU¯#«#Ñ-UÑSTÓ-U¯#¯#ª#Ñ-UÑSTÓ-UÓ*U€KßßÜ�q“'×"Ñ"ˆCÜ˜!œT×"Ò"ÜÑ[¬9°Q¬<Ó[Ó[�Ø˜ E 7¨$¬t°AµH«~×/FÑ/FÐ.GÐHÕH�ØDÀSÀEÈÐKˆIÜ ØÜ  ›GÜ"¤5§<¡<Õ0ôð ñ
 Ùr"   c               ó(   € V ^8„  d   QhRRRRRRRR/# ©r   rE   rF   ÚyrH   r   r   r   )r   s   "r    r!   r!   l  s)   € ÷ *ñ * ð *°ð *Àtð *ÐW[ñ *r"   c                ón  € \         P                  P                  4       '       g   \        '       g   R# V P                  VP                  8w  dh   V'       d^   RpVRV P                   R2,          pVRVP                   2,          p\        VV P                  VP                  .V P                  R7      hR# R# )aõ  Check that two tensors are on the same device.

``KORNIA_CHECK_SAME_DEVICE(x, y)`` returns ``True`` when ``x.device == y.device``. On failure it raises
:exc:`~kornia.core.exceptions.DeviceError`.

Args:
    x: first tensor to evaluate.
    y: second tensor to evaluate.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    DeviceError: if the two tensors are not on the same device and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_SAME_DEVICES`: checks a list of tensors against the first one.

Example:
    >>> x1 = torch.rand(2, 3, 3)
    >>> x2 = torch.rand(1, 3, 1)
    >>> KORNIA_CHECK_SAME_DEVICE(x1, x2)
    True

Tz5Device mismatch: tensors must be on the same device.
z  First tensor device: rN   z  Second tensor device: ©Úactual_devicesÚexpected_deviceF)r3   r4   r5   r.   r…   r   )rE   rÆ   rH   rb   s   &&& r    ÚKORNIA_CHECK_SAME_DEVICErË   l  s•   € ô6 �9‰9×!Ñ!×#Ò#ß%Ó%Ùà‡x�x�1—8‘8ÔßØPˆIØÐ2°1·8±8°*¸BÐ?Õ?ˆIØÐ3°A·H±H°:Ð>Õ>ˆIÜØØ !§¡¨!¯(©(Ð3Ø !§¡ôð ñ
 Ùr"   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Útensorszlist[torch.Tensor]r0   r1   rH   r   r   r   )r   s   "r    r!   r!   ™  s2   € ÷ Gñ GØðGØ&<ðGØMQðGà	ñGr"   c                ó¸  a € \         P                  P                  4       '       g   \        '       g   R# \	        S \
        4      '       dK   \        S 4      ^ 8”  d;   \        ;QJ d    R S  4       F  '       d   K   RM	  RM! R S  4       4      '       gø   V'       dî   \        V4      pRpVf   RMRV 2p\	        S \
        4      '       g7   \        V R\        S 4      P                   RV 2\        S 4      \
        R	7      h\        S 4      ^ 8X  d   \        V R
V 24      hS  Fc  p\	        V\         P                  4      '       d   K%  \        V R\        V4      P                   RV 2\        V4      \         P                  R	7      h	  R# \        ;QJ d    V 3R lS  4       F  '       d   K   RM	  RM! V 3R lS  4       4      '       g‹   V'       d�   \        V4      pS  Uu. uF  qUP                  NK  	  ppRpVRS ^ ,          P                   R2,          pVRV 2,          pVe   VRV 2,          p\        VVS ^ ,          P                  R7      hR# R# u upi )aâ  Check that every tensor of a non-empty list is on the device of the first.

``KORNIA_CHECK_SAME_DEVICES(tensors)`` returns ``True`` when ``tensors`` is a non-empty ``list`` of tensors that are
all on ``tensors[0].device``. A tuple, an empty list or an element that is not a tensor raises
:exc:`~kornia.core.exceptions.TypeCheckError`, and tensors on different devices raise
:exc:`~kornia.core.exceptions.DeviceError`.

Args:
    tensors: a non-empty list of tensors.
    msg: message to show in the exception, or a function that returns it; see :func:`KORNIA_CHECK`.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    TypeCheckError: if tensors is not a non-empty list of tensors and raises is True.
    DeviceError: if the tensors are not all on the same device and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_SAME_DEVICE`: compares two tensors.
    - :func:`KORNIA_CHECK_IS_LIST_OF_TENSOR`: checks the list type only, and accepts an empty list.

Example:
    >>> x1 = torch.rand(2, 3, 3)
    >>> x2 = torch.rand(1, 3, 1)
    >>> KORNIA_CHECK_SAME_DEVICES([x1, x2], "Tensors not in the same device")
    True

Tc              3  óV   "  € T F  p\        V\        P                  4      x € K!  	  R # 5iro   r¸   )ru   rE   s   & r    rw   Ú,KORNIA_CHECK_SAME_DEVICES.<locals>.<genexpr>¾  s$   é € ÐBpÑhoÐcdÄ:ÈaÔQV×Q]ÑQ]×C^ÐC^Óhoùr»   Fz)Expected a non-empty list of tensors, gotÚ rP   Ú r¨   r©   z an empty list.z a list containing c              3  ód   <"  € T F%  pS^ ,          P                   VP                   8H  x € K'  	  R# 5i)é    N)r…   )ru   rE   rÍ   s   & €r    rw   rÐ   Ñ  s$   øé € Ð>±g°ˆw�q�z× Ñ  A§H¡HÖ,³gùs   ƒ-0z9Device mismatch: all tensors must be on the same device.
z  Expected device: rN   z  Actual devices: rÈ   )r3   r4   r5   r.   r¬   rY   rW   r½   r7   r   r†   rŸ   r³   r…   r   )rÍ   r0   rH   ÚprefixÚsuffixrE   Údevicesrb   s   f&&     r    ÚKORNIA_CHECK_SAME_DEVICESrØ   ™  sý  ø€ ôB �9‰9×!Ñ!×#Ò#ß%Ó%Ùä�w¤×%Ò%¬#¨g«,¸Ô*:¿s»sÑBpÑhoÓBp¿s¿sºsÑBpÑhoÓBp×?pÒ?pßÜ˜sÓ#ˆCØ@ˆFØš;‘R¨d°3°%¨LˆFÜ˜g¤t×,Ò,Ü$Ø�h˜a¤ W£× 6Ñ 6Ð7°q¸¸ÐAÌtÐT[Ë}Ôlpôð ô �7‹|˜qÔ Ü$¨ x¨¸v¸hÐ%GÓHÐHÛ�Ü! !¤U§\¡\×2Ô2Ü(Ø!˜(Ð"5´d¸1³g×6FÑ6FÐ5GÀqÈÈÐQÜ$(¨£GÜ&+§l¡lôð ñ ñ ß‹3Ô>±gÓ>�3�3Š3Ô>±gÓ>×>Ò>ßÜ˜sÓ#ˆCÙ)0Ó1© A—x”x©ˆGÐ1ØTˆIØÐ.¨w°q­z×/@Ñ/@Ð.AÀÐDÕDˆIØÐ-¨g¨YÐ7Õ7ˆIØŠØ˜t C 5˜\Õ)�	ÜØØ&Ø '¨¥
× 1Ñ 1ôð ñ
 Ùùò 2s   Ç"Ic               ó(   € V ^8„  d   QhRRRRRRRR/# rÅ   r   )r   s   "r    r!   r!   ã  s)   € ÷ -ñ -˜|ð -°ð -Àdð -ÐVZñ -r"   c                óZ  € \         P                  P                  4       '       g   \        '       g   R# V P                  VP                  8w  d^   V'       dT   Rp\        V P                  4      p\        VP                  4      pVRV R2,          pVRV 2,          p\        VVVR7      hR# R# )a   Check that two tensors have exactly the same shape.

``KORNIA_CHECK_SAME_SHAPE(x, y)`` returns ``True`` when ``x.shape == y.shape``; shapes that only broadcast, such as
``(1, 3)`` and ``(2, 3)``, fail. On failure it raises :exc:`~kornia.core.exceptions.ShapeError`.

Args:
    x: first tensor to evaluate.
    y: second tensor to evaluate.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    ShapeError: if the two tensors do not have the same shape and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_SAME_SIZE`: compares one dimension, optionally accepting a size of 1.
    - :func:`KORNIA_CHECK_SHAPE`: compares one tensor with a pattern instead of another tensor.

Example:
    >>> x1 = torch.rand(2, 3, 3)
    >>> x2 = torch.rand(2, 3, 3)
    >>> KORNIA_CHECK_SAME_SHAPE(x1, x2)
    True

Tz2Shape mismatch: tensors must have the same shape.
ú  First tensor shape: rN   ú  Second tensor shape: rQ   F)r3   r4   r5   r.   rG   rY   r   )rE   rÆ   rH   rb   rc   Úy_shape_lists   &&&   r    ÚKORNIA_CHECK_SAME_SHAPErÞ   ã  s–   € ô8 �9‰9×!Ñ!×#Ò#ß%Ó%Ùà‡w�w�!—'‘'ÔßØMˆIÜ §¡›=ˆLÜ §¡›=ˆLØÐ1°,°¸rÐBÕBˆIØÐ2°<°.ÐAÕAˆIÜØØ)Ø+ôð ñ
 Ùr"   c               ó4   € V ^8„  d   QhRRRRRRRRRR	R
RRR/# )r   rE   rF   rÆ   rf   r\   Ú	allow_oner   r0   r1   rH   r   r   )r   s   "r    r!   r!     sW   € ÷ Iñ IØðIàðIð 
ðIð ð	Ið
 
 ðIð ðIð 
ñIr"   c                óF  € \         P                  P                  4       '       g   \        '       g   R# V P                  VP                  rv\        V4      \        V4      r˜V) Tu;8*  ;'       d    V8  Mu ;'       d    V	) Tu;8*  ;'       d    V	8  Mu p
V
'       dZ   V'       d*   \        Wb,          \        4      '       d   Wb,          ^8X  gÔ   Wb,          Wr,          8X  gÁ   V'       d   Wb,          ^8X  g¬   V'       d¢   \        V4      p\        V4      p\        V4      pV
'       g   RV R2pM;V'       d   Wr,          ^8w  d   Wr,           R2MWr,           pRV RV RWb,           R2pVRV R	2,          pVR
V 2,          pVe   VRV 2,          p\        WÛVR7      hR# R# )a˜  Check that two tensors have the same size along one dimension.

``KORNIA_CHECK_SAME_SIZE(x, y, dim)`` returns ``True`` when ``x.shape[dim] == y.shape[dim]``; with
``allow_one=True``, a size of 1 in ``x``, not in ``y``, also passes. A ``dim`` that either tensor lacks fails. On
failure it raises :exc:`~kornia.core.exceptions.ShapeError`.

Args:
    x: the tensor to evaluate.
    y: the reference tensor.
    dim: the dimension to compare; negative values count from the end.
    allow_one: also accept a size of 1 for ``x``, such as a kernel or a parameter shared by the whole batch.
    msg: message to append to the error, or a function that returns it; see :func:`KORNIA_CHECK`.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    ShapeError: if a tensor has no dimension ``dim``, or the sizes differ (and that of ``x`` is not 1 with
        ``allow_one``), and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_SAME_SHAPE`: compares every dimension, with no exception for a size of 1.
    - :func:`KORNIA_CHECK_SIZES`: compares every dimension with given sizes.

Example:
    >>> image = torch.rand(4, 3, 8, 8)
    >>> sigma = torch.rand(1, 2)
    >>> KORNIA_CHECK_SAME_SIZE(sigma, image, allow_one=True)
    True
    >>> KORNIA_CHECK_SAME_SIZE(torch.rand(2, 2), image, raises=False)
    False

Tz-Size mismatch: the tensors have no dimension rL   z or 1zSize mismatch at dimension rT   rU   rÛ   rN   rÜ   rP   rQ   F)r3   r4   r5   r.   rG   rW   r¬   r\   r7   rY   r   )rE   rÆ   rf   rà   r0   rH   Úx_shapeÚy_shapeÚx_ndimÚy_ndimÚin_rangerc   rÝ   rb   Úexpecteds   &&&&&&         r    ÚKORNIA_CHECK_SAME_SIZErè     sg  € ôT �9‰9×!Ñ!×#Ò#ß%Ó%Ùð —w‘w §¡ˆWÜ˜“\¤3 w£<ˆFØˆw˜#×&Ô& Ô&×BÐB¨F¨7°c×+BÔ+B¸FÔ+B€H÷ ß	”z '¥,´×4Ò4¸½ÈÔ9JØ�<˜7�<Ô'ß˜'�,¨!Ô+çÜ˜sÓ#ˆCÜ ›=ˆLÜ ›=ˆLßØKÈCÈ5ÐPSÐT‘	ç5>À7Å<ÐSTÔCT˜g�l˜^¨5Ñ1Ð]dÕ]iÐ\j�Ø9¸#¸¸kÈ(ÈÐSYÐZaÕZfÐYgÐgjÐk�	ØÐ1°,°¸rÐBÕBˆIØÐ2°<°.ÐAÕAˆIØŠØ˜t C 5˜\Õ)�	Ü˜YÐR^Ô_Ð_ÙÙr"   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R/# )
r   rE   rF   Úsizeszlist[Optional[int]]r0   r1   rH   r   r   r   )r   s   "r    r!   r!   _  s4   € ÷ <ñ <Øð<Ø/ð<Ø6Lð<Ø]að<à	ñ<r"   c                óŽ  € \         P                  P                  4       '       g   \        '       g   R# V P                  p\        V4      \        V4      8H  pV'       d;   \        \        V4      4       F"  pW,          pVf   K  WF,          V8w  g   K   Rp M	  V'       g¦   V'       dœ   \        V4      p. pV F#  pTP                  Vf   RM
\        V4      4       K%  	  \        V P                  4      p	RP                  V4      \        V4      ^8X  d   RMR,           p
RV
 RV	 R	2pVe   VR
V 2,          p\        W¹VR7      hR# R# )aZ  Check a tensor's sizes against integers computed at run time, None for any size.

``KORNIA_CHECK_SIZES(x, [n, None])`` returns ``True`` when ``x`` has ``len(sizes)`` dimensions and every size that
is not ``None`` equals the size of its dimension. On failure it raises :exc:`~kornia.core.exceptions.ShapeError`.
Under a dynamic-shape ``torch.compile`` it compares the sizes without specializing them.

Args:
    x: the tensor to evaluate.
    sizes: the expected size of every dimension, or ``None`` for a dimension of any size.
    msg: message to append to the error, or a function that returns it; see :func:`KORNIA_CHECK`.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    ShapeError: if the tensor does not have ``len(sizes)`` dimensions, or one of them differs from a given size, and
        raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_SHAPE`: takes a pattern of strings, with a ``"*"`` for any number of dimensions.
    - :func:`KORNIA_CHECK_SAME_SIZE`: compares one dimension with another tensor's, optionally accepting 1.

Example:
    >>> pred = torch.rand(2, 5, 4, 4)
    >>> weight = torch.rand(5)
    >>> KORNIA_CHECK_SIZES(weight, [pred.shape[1]])
    True
    >>> KORNIA_CHECK_SIZES(pred, [2, None, 4, 4])
    True

TFrJ   ú, Ú,rÑ   zShape mismatch: expected (z), got r¨   rP   rQ   )r3   r4   r5   r.   rG   rW   rZ   r7   Úappendr~   rY   r    r   )rE   rê   r0   rH   râ   Úmatchesrd   Úsizerç   rc   Úexpected_strrb   s   &&&&        r    ÚKORNIA_CHECK_SIZESrò   _  s  € ôF �9‰9×!Ñ!×#Ò#ß%Ó%Ùà�g‰g€GÜ�'‹lœc %›jÑ(€GßÜ”s˜5“zÖ"ˆAØ•8ˆDØÔ G¥J°$Ö$6Ø�Ùñ	 #÷
 ßÜ˜sÓ#ˆCØ"$ˆHÛ�Ø—‘ t¢|¡¼¸T»ÖCñ ä §¡›=ˆLØŸ9™9 XÓ.¼¸X»È!Ô9K±#ÐQSÕTˆLØ4°\°NÀ'È,ÈÐWXÐYˆIØŠØ˜t C 5˜\Õ)�	Ü˜YÐRZÔ[Ð[ÙÙr"   c               ó(   € V ^8„  d   QhRRRRRRRR/# ©r   rE   rF   r0   r1   rH   r   r   r   )r   s   "r    r!   r!   ž  s+   € ÷ )ñ )˜\ð )Ð0Fð )ÐW[ð )Ðgkñ )r"   c                ó`  € \         P                  P                  4       '       g   \        '       g   R# \	        V P
                  4      ^8  g   V P
                  R,          ^8w  dJ   V'       d@   \        V4      pR\        V P
                  4       R2pVe   VRV 2,          p\        V4      hR# R# )a;  Check that an image tensor is color, with three channels at dimension -3.

``KORNIA_CHECK_IS_COLOR(x)`` returns ``True`` when ``x`` has at least three dimensions and ``x.shape[-3] == 3``, as
in ``(*, 3, H, W)``. On failure it raises :exc:`~kornia.core.exceptions.ImageError`.

Args:
    x: image tensor to evaluate.
    msg: message to show in the exception, or a function that returns it; see :func:`KORNIA_CHECK`.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    ImageError: if ``x`` does not have a shape ``(*, 3, H, W)`` and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_IS_GRAY`: one channel, or a 2D ``(H, W)`` tensor.
    - :func:`KORNIA_CHECK_IS_COLOR_OR_GRAY`: one or three channels.
    - :func:`KORNIA_CHECK_IS_IMAGE`: one or three channels, and values in :math:`[0, 1]`, or up to ``2 ** bits - 1``
      for integers.

Example:
    >>> img = torch.rand(2, 3, 4, 4)
    >>> KORNIA_CHECK_IS_COLOR(img, "Image is not color")
    True

TzNot a color tensor. Got shape r¨   rN   Féýÿÿÿ©	r3   r4   r5   r.   rW   rG   r7   rY   r   ©rE   r0   rH   rb   s   &&& r    ÚKORNIA_CHECK_IS_COLORrù   ž  sˆ   € ô: �9‰9×!Ñ!×#Ò#ß%Ó%Ùä
ˆ1�7‰7ƒ|�aÔ˜1Ÿ7™7 2�;¨!Ô+ßÜ˜sÓ#ˆCØ8¼¸a¿g¹g»¸ÀqÐIˆIØŠØ˜r # ˜ZÕ'�	Ü˜YÓ'Ð'ÙÙr"   c               ó(   € V ^8„  d   QhRRRRRRRR/# rô   r   )r   s   "r    r!   r!   Ê  s+   € ÷ 'ñ '˜Lð 'Ð/Eð 'ÐVZð 'Ðfjñ 'r"   c                ó”  € \         P                  P                  4       '       g   \        '       g   R# \	        V P
                  4      ^8  g3   \	        V P
                  4      ^8¼  db   V P
                  R,          ^8w  dJ   V'       d@   \        V4      pR\        V P
                  4       R2pVe   VRV 2,          p\        V4      hR# R# )a¯  Check that an image tensor is gray, with one channel at dimension -3 or none.

``KORNIA_CHECK_IS_GRAY(x)`` returns ``True`` for a ``(*, 1, H, W)`` tensor and for any 2D tensor, read as
``(H, W)``. On failure it raises :exc:`~kornia.core.exceptions.ImageError`.

Args:
    x: image tensor to evaluate.
    msg: message to show in the exception, or a function that returns it; see :func:`KORNIA_CHECK`.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    ImageError: if ``x`` is neither ``(*, 1, H, W)`` nor 2D and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_IS_COLOR`: three channels.
    - :func:`KORNIA_CHECK_IS_COLOR_OR_GRAY`: one or three channels, and rejects a 2D ``(H, W)`` tensor.

Example:
    >>> img = torch.rand(2, 1, 4, 4)
    >>> KORNIA_CHECK_IS_GRAY(img, "Image is not grayscale")
    True

TzNot a gray tensor. Got shape r¨   rN   Frö   r÷   rø   s   &&& r    ÚKORNIA_CHECK_IS_GRAYrü   Ê  s—   € ô6 �9‰9×!Ñ!×#Ò#ß%Ó%Ùä
ˆ1�7‰7ƒ|�aÔœC §¡›L¨AÔ-°!·'±'¸"µ+ÀÔ2BßÜ˜sÓ#ˆCØ7¼¸Q¿W¹W»°ÀaÐHˆIØŠØ˜r # ˜ZÕ'�	Ü˜YÓ'Ð'ÙÙr"   c               ó(   € V ^8„  d   QhRRRRRRRR/# rô   r   )r   s   "r    r!   r!   ô  s+   € ÷ *ñ * \ð *Ð8Nð *Ð_cð *Ðosñ *r"   c                ó`  € \         P                  P                  4       '       g   \        '       g   R# \	        V P
                  4      ^8  g   V P
                  R,          R9  dJ   V'       d@   \        V4      pR\        V P
                  4       R2pVe   VRV 2,          p\        V4      hR# R# )aº  Check that an image tensor has one or three channels at dimension -3.

``KORNIA_CHECK_IS_COLOR_OR_GRAY(x)`` returns ``True`` when ``x`` is ``(*, 1, H, W)`` or ``(*, 3, H, W)``; unlike
:func:`KORNIA_CHECK_IS_GRAY`, it rejects a 2D ``(H, W)`` tensor. It checks the shape only, not the dtype or the
values. On failure it raises :exc:`~kornia.core.exceptions.ImageError`.

Args:
    x: image tensor to evaluate.
    msg: message to show in the exception, or a function that returns it; see :func:`KORNIA_CHECK`.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    ImageError: if ``x`` does not have a shape ``(*, 1, H, W)`` or ``(*, 3, H, W)`` and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_IS_IMAGE`: the same shape check, and values in :math:`[0, 1]`, or up to ``2 ** bits - 1``
      for integers.
    - :func:`KORNIA_CHECK_IS_COLOR`: three channels only.
    - :func:`KORNIA_CHECK_IS_GRAY`: one channel only, or a 2D ``(H, W)`` tensor.

Example:
    >>> img = torch.rand(2, 3, 4, 4)
    >>> KORNIA_CHECK_IS_COLOR_OR_GRAY(img, "Image is not color or grayscale")
    True

Tz&Not a color or gray tensor. Got shape r¨   rN   Frö   )rK   é   r÷   rø   s   &&& r    ÚKORNIA_CHECK_IS_COLOR_OR_GRAYr   ô  sˆ   € ô< �9‰9×!Ñ!×#Ò#ß%Ó%Ùä
ˆ1�7‰7ƒ|�aÔ˜1Ÿ7™7 2�;¨fÔ4ßÜ˜sÓ#ˆCØ@ÄÀaÇgÁgÃÀÈqÐQˆIØŠØ˜r # ˜ZÕ'�	Ü˜YÓ'Ð'ÙÙr"   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R/# )
r   rE   rF   r0   r1   rH   r   Úbitsr\   r   r   )r   s   "r    r!   r!   %  s4   € ÷ =ñ =Øð=Ø0ð=ØAEð=ØTWð=à	ñ=r"   c                ó   € \         P                  P                  4       '       g   \        '       g   R# \	        WV4      '       g   R# V P                  4       ^ 8X  d   R# ^ pV P                  \         P                  \        \        \        39   d   RRreM˜^ ^V,          ^,
          re\        P                  V P                  4      pVee   V P                  V4      \         P                  ! V4      P                  ,          p ^\         P                  ! V4      P                   ^,
          ,          p\         P"                  ! \         P$                  ! V 4      4      P'                  4       w  r‰W„,           W”,           r˜WX8:  d   W–8:  g   \)        WW‰WV34      # R# )a;  Check that a tensor is a color or gray image in [0, 1], or [0, 255] for integers by default.

``KORNIA_CHECK_IS_IMAGE(x)`` returns ``True`` when ``x`` is ``(*, 1, H, W)`` or ``(*, 3, H, W)`` and its values lie
in :math:`[0, 1]` for a floating dtype, or from ``0`` to ``2 ** bits - 1`` for an integer or boolean dtype of any
width. A NaN or an infinity fails, and an empty image passes. The minimum and maximum are read on the host, so the
check waits for an accelerator and breaks a ``torch.compile`` graph, and TorchScript cannot compile it.

Args:
    x: image tensor to evaluate.
    msg: message to show in the exception, or a function that returns it; see :func:`KORNIA_CHECK`.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.
    bits: the bit depth of an integer image; the default 8 accepts values up to 255. A floating image ignores it.

Raises:
    ImageError: if the tensor shape is invalid and raises is True.
    ValueCheckError: if the tensor value range is invalid and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`KORNIA_CHECK_IS_COLOR_OR_GRAY`: the same shape check, without reading the values.

Example:
    >>> img = torch.rand(2, 3, 4, 4)
    >>> KORNIA_CHECK_IS_IMAGE(img, "It is not an image")
    True

TFg        g      ð?)r3   r4   r5   r.   r   ÚnumelÚdtypeÚbfloat16r   r   r   Ú_UNSIGNED_AS_SIGNEDÚgetÚviewÚiinfoÚminr  r{   ÚaminmaxÚtolistÚ_handle_invalid_range)
rE   r0   rH   r  ÚoffsetÚlowÚhighÚsignedÚaminÚamaxs
   &&&&      r    ÚKORNIA_CHECK_IS_IMAGEr  %  s  € ô@ �9‰9×!Ñ!×#Ò#ß%Ó%Ùä(¨°×8Ò8Ùà‡w�wƒy�A„~Ùà€FØ‡w�w”5—>‘>¤7¬G´WÐ=Ô=Ø˜‰Tà˜˜T�	 Q•ˆTÜ$×(Ñ(¨¯©Ó1ˆØÒð —‘�v“¤§¢¨VÓ!4×!8Ñ!8Õ8ˆAØœ5Ÿ;š; vÓ.×3Ñ3°aÕ7Õ8ˆFô —’œUŸ]š]¨1Ó-Ó.×5Ñ5Ó7�J€DØ• ¥ˆ$ØŒK˜DœLÜ$ S°$¸s¸kÓJÐJár"   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )r   Údesc1rF   Údesc2ÚdmrH   r   r   r   )r   s   "r    r!   r!   e  s8   € ÷ Bñ B ð B°\ð BÀ|ð BÐ]að BÐmqñ Br"   c           
     ó   € \         P                  P                  4       '       g   \        '       g   R# VP	                  4       ^8  g+   V P	                  4       ^8  g   VP	                  4       ^8  dm   V'       dc   \        R\        VP                  4       R\        V P                  4       R\        VP                  4       2\        VP                  4      R7      hR# VP                  ^ 4      V P                  ^ 4      8X  d&   VP                  ^4      VP                  ^ 4      8X  g×   V'       dÍ   V P                  ^ 4      VP                  ^ 4      3pV P                  ^ 4      pVP                  ^ 4      pRpVRV R	V R
V R2,          p\        VP                  4      p\        V P                  4      p	\        VP                  4      p
VRV R2,          pVRV	 R2,          pVRV
 2,          p\        VVVR7      hR# R# )aý  Check that a distance matrix's first two sizes match the counts of two descriptor sets.

``KORNIA_CHECK_DM_DESC(desc1, desc2, dm)`` returns ``True`` when ``dm.shape[0] == desc1.shape[0]`` and
``dm.shape[1] == desc2.shape[0]``, as for ``(N, D)`` and ``(M, D)`` descriptors and their ``(N, M)`` distance
matrix. Only these sizes are compared: further dimensions of ``dm`` and the descriptor size ``D`` are not checked,
and a ``dm`` with fewer than two dimensions or a 0-dimensional descriptor fails. On failure it raises
:exc:`~kornia.core.exceptions.ShapeError`.

Args:
    desc1: first descriptor tensor to evaluate.
    desc2: second descriptor tensor to evaluate.
    dm: distance matrix tensor to evaluate.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    ShapeError: if the shapes of the descriptors do not match the distance matrix and raises is True.

Note:
    Skipped while checks are disabled; see :func:`disable_checks`.

See Also:
    - :func:`~kornia.feature.match_nn`: a matcher that runs this check on a distance matrix passed as ``dm``.

Example:
    >>> desc1 = torch.rand(4, 128)
    >>> desc2 = torch.rand(8, 128)
    >>> dm = torch.rand(4, 8)
    >>> KORNIA_CHECK_DM_DESC(desc1, desc2, dm)
    True

Tz…Distance matrix shape mismatch.
  Expected a distance matrix with at least 2 dimensions and descriptors with at least 1.
  dm shape: z, desc1 shape: z, desc2 shape: )rR   Fz Distance matrix shape mismatch.
rM   z (from desc1.shape[0]=z, desc2.shape[0]=z)
rO   rN   z  desc1 shape: z  desc2 shape: rQ   )	r3   r4   r5   r.   rf   r   rY   rG   rð   )r  r  r  rH   rS   Ú
desc1_sizeÚ
desc2_sizerb   Údm_shape_listÚdesc1_shape_listÚdesc2_shape_lists   &&&&       r    ÚKORNIA_CHECK_DM_DESCr   e  sÀ  € ô@ �9‰9×!Ñ!×#Ò#ß%Ó%Ùà	‡v�vƒx�!„|�u—y‘y“{ Q”¨%¯)©)«+¸¬/ßÜðä# B§H¡H›~Ð.¨o¼dÀ5Ç;Á;Ó>OÐ=PÐP_Ô`dÐej×epÑepÓ`qÐ_rðtô " "§(¡(›^ô	ð ñ Ø�W‰W�Q‹Z˜5Ÿ:™: a›=Ô(¨r¯w©w°q«z¸U¿Z¹ZÈ»]Ô/JßØ#Ÿj™j¨›m¨U¯Z©Z¸«]Ð;ˆNØŸ™ A›ˆJØŸ™ A›ˆJØ;ˆIØØ$ ^Ð$4Ð4JÈ:È,ÐVgÐhrÐgsÐsvÐwõˆIô ! §¡›NˆMÜ# E§K¡KÓ0ÐÜ# E§K¡KÓ0ÐØÐ+¨M¨?¸"Ð=Õ=ˆIØ˜?Ð+;Ð*<¸BÐ?Õ?ˆIØ˜?Ð+;Ð*<Ð=Õ=ˆIÜØØ*Ø-ôð ñ
 Ùr"   c               ó$   € V ^8„  d   QhRRRRRR/# )r   ÚlafrF   rH   r   r   r   )r   s   "r    r!   r!   ª  s&   € ÷ Hñ H˜,ð H°ð HÀñ Hr"   c                ó"   € \        V . ROVR7      # )aâ  Check that a tensor has the shape of local affine frames, (B, N, 2, 3).

``KORNIA_CHECK_LAF(laf)`` returns ``True`` when ``laf`` is ``(B, N, 2, 3)``; it is
``KORNIA_CHECK_SHAPE(laf, ["B", "N", "2", "3"])``. On failure it raises :exc:`~kornia.core.exceptions.ShapeError`.

Convention:
    Only the shape is checked: any dtype and any values pass, ``N = 0`` included.

Args:
    laf: local affine frame tensor to evaluate.
    raises: whether to raise on failure; with ``False``, the check returns ``False`` instead.

Raises:
    ShapeError: if ``laf`` does not have a shape ``(B, N, 2, 3)`` and raises is True.

Note:
    Skipped while checks are disabled; see :func:`~kornia.core.check.disable_checks`.

See Also:
    - :func:`~kornia.feature.laf_is_valid`: checks the values: finite entries and a nonzero determinant.
    - :func:`~kornia.core.check.KORNIA_CHECK_SHAPE`: checks any other shape pattern.

Example:
    >>> lafs = torch.rand(2, 10, 2, 3)
    >>> KORNIA_CHECK_LAF(lafs)
    True

)rH   )ÚBÚNÚ2Ú3)rg   )r"  rH   s   &&r    ÚKORNIA_CHECK_LAFr(  ª  s   € ô: ˜cÒ#7ÀÔGÐGr"   c               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )r   r0   r1   rH   r   Úmin_valÚfloatÚmax_valÚexpected_rangeztuple[float, float]r   r   )r   s   "r    r!   r!   Ê  s<   € ÷ ñ Ø	ðØ)-ðØ8=ðØHMðØ_rðà	ñr"   c           	     óž   € V'       dE   R V 4       w  rVRV RV RV RV R2	p\        V 4      p V e   VRV  2,          p\        VW#3VR7      hR# )	zHandle invalid range cases.c              3  ó\   "  € T F"  p\        V\        4      '       d   VR  MT x € K$  	  R# 5i)ÚgN)r¬   r+  )ru   Úbs   & r    rw   Ú(_handle_invalid_range.<locals>.<genexpr>Ï  s'   é € ÐZÉ>Àa¤¨A¬u×!5Ò!5˜˜!‘u¸a¸SÔAË>ùs   ‚*,z Value range mismatch: expected [rì   z], got [z].rP   )Úactual_valuer-  F)r7   r   )r0   rH   r*  r,  r-  r  r  Úerr_msgs   &&&&&   r    r  r  Ê  st   € ÷ ÙZÉ>ÓZ‰	ˆØ4°S°E¸¸D¸6ÀÈ'ÈÐRTÐU\ÐT]Ð]_Ð`ˆÜ˜3ÓˆØŠ?Ø˜˜c˜U�|Õ#ˆGÜØØ!Ð+Ø)ô
ð 	
ñ
 r"   )rk   r   rù   r   rü   r  rÃ   r´   r(  rË   rØ   rÞ   rè   rg   rò   r°   r•   r   r   r   r   r   r   r   r;   r@   rC   )NT)F)T)rÔ   FNT)NTé   )IÚ__conditional_annotations__Ú__doc__Ú
__future__r   r)   Útypesr   Útypingr   r   r   r   r   r	   r
   r   r   r   r3   r   r   r   Úkornia.core._compatr   Úkornia.core.exceptionsr   r   r   r   r   r   r   Ú__all__r-   r.   Ú__annotations__rŠ   r~   ÚCheckMessager7   r;   r@   rC   rg   rk   r|   r�   r•   r†   r–   rœ   r°   r´   rÃ   rË   rØ   rÞ   rè   rò   rù   rü   r   Úuint16Úint16Úuint32Úint32Úuint64Úint64r  r  r   r(  r  )r6  s   @r    Ú<module>rF     sY  øðô$õ< #ã 	Ý ß o× o× oã ß +Ñ +å 0÷÷ ñ ò€õ>ñ(  5Ó6Ð ˜Ó 6ñ )¨¨BÓ/Ð çà˜˜h r¨3 wÕ/Ð/Õ0�Lð €Lõõ"õ,#õ."÷*a÷H0õfo÷8,õv ñ, ˆT˜Ô€õ/÷7÷t4÷n/÷d*÷ZG÷T-÷`I÷X<÷~)÷X'÷T*ð\ —|‘| U§[¡[°%·,±,ÀÇÁÈUÏ\É\Ð[`×[fÑ[fÐgÐ ÷=÷@B÷JH÷@r"   