+
    åûjM8  ã                   óR   € R t ^ RIHt ^ RIt^ RIHt RR.tR
R R lltRR R	 lltR# )aK  Grids of pixel and voxel coordinates, normalized to [-1, 1] for grid_sample or in pixels.

Coordinates are ``(x, y)`` = (column, row) in 2D and ``(d, x, y)``, depth first, in 3D, with integer pixel centres;
see :ref:`Coordinates and sizes <coordinate-conventions>`. A normalized grid maps the first and last pixel centres of
each axis to ``-1`` and ``1`` by default, the ``align_corners=True`` convention of
:func:`torch.nn.functional.grid_sample`.

Which function to use:

- The ``(1, H, W, 2)`` grid of ``(x, y)`` coordinates of an image: :func:`create_meshgrid`, which can also normalize
  to the half-pixel ``align_corners=False`` convention.
- The ``(1, D, H, W, 3)`` grid of ``(d, x, y)`` coordinates of a volume: :func:`create_meshgrid3d`, corner-aligned
  only; reorder its last axis with ``grid[..., [1, 2, 0]]`` for ``grid_sample``.
)ÚOptionalN)Úis_compilingÚcreate_meshgridÚcreate_meshgrid3dc                óÔ   € V ^8„  d   QhR\         R\         R\        R\        \        P                  ,          R\        \        P
                  ,          R\        R\        P                  /# )é   ÚheightÚwidthÚnormalized_coordinatesÚdeviceÚdtypeÚalign_cornersÚreturn©ÚintÚboolr   Útorchr   r   ÚTensor)Úformats   "ÚPC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\grid.pyÚ__annotate__r   *   sm   € ÷ K3ñ K3ÜðK3äðK3ô !ðK3ô ”U—\‘\Õ"ð	K3ô
 ”E—K‘KÕ ðK3ô ðK3ô ‡\�\ñK3ó    c                óB  € Ve   TM!\         P                  ! ^ VR7      P                  pT;'       d$    V\         P                  \         P                  39   pV'       d   \         P
                  MTp\         P                  ! WVR7      p	\         P                  ! WVR7      p
V'       Edþ   \         P                  P                  4       '       Eg:   \         P                  P                  4       '       g   \        4       '       Ed   \         P                  ! WP                  VR7      p\         P                  ! W
P                  VR7      pV'       d|   \         P                  ! V^8„  W›^,
          ,          R,
          ^,          V	R,          4      p	\         P                  ! V^8„  W¬^,
          ,          R,
          ^,          V
R,          4      p
MÜRV	,          R,           V,          R,
          p	RV
,          R,           V,          R,
          p
MŸV'       d\   V^8”  d   W‘^,
          ,          R,
          ^,          MV	R,          p	V ^8”  d   W ^,
          ,          R,
          ^,          MV
R,          p
M<RV	,          R,           V,          R,
          p	RV
,          R,           V ,          R,
          p
V'       d#   V	P                  V4      p	V
P                  V4      p
\         P                  ! \         P                   ! Wš.RR7      R
R	7      pVP#                  ^^ ^4      P%                  ^ 4      # )ay  Generate a (1, H, W, 2) grid of (x, y) pixel coordinates, in [-1, 1] by default.

``grid = create_meshgrid(H, W)`` returns the ``(x, y)`` coordinates of every pixel of an ``H x W`` image as a
``(1, H, W, 2)`` tensor, ``grid[0, i, j]`` holding column ``j`` and row ``i``: normalized to :math:`[-1, 1]` by
default, or in pixels, ``0`` to ``W - 1`` and ``H - 1``, with ``normalized_coordinates=False``. A normalized grid
is the identity sampling grid of :func:`torch.nn.functional.grid_sample` called with the same ``align_corners``.
For the ``(1, D, H, W, 3)`` grid of a volume, use :func:`create_meshgrid3d`.

Convention:
    - Coordinates follow :ref:`Coordinates and sizes <coordinate-conventions>`. With
      ``normalized_coordinates=True``, the ``align_corners`` argument selects the matching
      :py:func:`torch.nn.functional.grid_sample` convention; pass the same flag to both calls. The default is
      corner-aligned (``align_corners=True``).
    - A size-1 axis is ``0`` under either flag, and a size-0 axis gives an empty grid.
    - An integer ``dtype`` is kept for a pixel grid; a normalized grid is then torch's default floating dtype.

Args:
    height: the image height (rows).
    width: the image width (cols).
    normalized_coordinates: whether to normalize
      coordinates in the range :math:`[-1,1]` in order to be consistent with the
      PyTorch function :py:func:`torch.nn.functional.grid_sample`.
    device: the device on which the grid will be generated.
    dtype: the data type of the generated grid.
    align_corners: which normalization convention to use when
      ``normalized_coordinates`` is ``True``. ``True`` maps pixel centers
      :math:`[0, size-1]` to :math:`[-1, 1]`; ``False`` uses the half-pixel
      mapping :math:`x_{norm} = (2x + 1) / W - 1`, where :math:`\pm 1` are the
      outer pixel *edges*. Ignored when ``normalized_coordinates`` is ``False``.

Return:
    grid tensor with shape ``(1, H, W, 2)``.

See Also:
    - :func:`create_meshgrid3d`: the ``(1, D, H, W, 3)`` grid of ``(d, x, y)`` voxel coordinates, corner-aligned
      only.
    - :func:`~kornia.geometry.conversions.normalize_pixel_coordinates`: normalizes given ``(x, y)`` pixel
      coordinates the way the default grid is normalized.
    - :func:`~kornia.geometry.transform.warp_grid`: applies homographies to this grid, without sampling.
    - :func:`~kornia.geometry.transform.remap`: samples an image at an x map and a y map, such as the two
      channels of a pixel grid plus a flow.
    - :func:`~kornia.geometry.depth.unproject_meshgrid`: the camera ray through every pixel instead of its
      coordinates.

Example:
    >>> create_meshgrid(2, 2)
    tensor([[[[-1., -1.],
              [ 1., -1.]],
    <BLANKLINE>
             [[-1.,  1.],
              [ 1.,  1.]]]])

    >>> create_meshgrid(2, 2, align_corners=False)
    tensor([[[[-0.5000, -0.5000],
              [ 0.5000, -0.5000]],
    <BLANKLINE>
             [[-0.5000,  0.5000],
              [ 0.5000,  0.5000]]]])

    >>> create_meshgrid(2, 2, normalized_coordinates=False)
    tensor([[[[0., 0.],
              [1., 0.]],
    <BLANKLINE>
             [[0., 1.],
              [1., 1.]]]])

©r   ©r   r   ç      à?ç        g       @g      ð?Úij©Úindexing©Údiméÿÿÿÿ©r   Úemptyr   Úfloat16Úbfloat16Úfloat32ÚarangeÚjitÚis_scriptingÚ
is_tracingr   Úscalar_tensorr   ÚwhereÚtoÚstackÚmeshgridÚpermuteÚ	unsqueeze)r   r	   r
   r   r   r   Ú
ramp_dtypeÚwidenedÚ
work_dtypeÚxsÚysÚwidth_tÚheight_tÚ	base_grids   &&&&&&        r   r   r   *   s2  € ðr  Ò+‘´·²¸QÀvÔ1N×1TÑ1T€Jð %×VÐV¨¼¿¹ÄuÇ~Á~Ð7VÑ)V€Gß")”—’¨z€JÜ	�Š�e°*Ô	=€BÜ	�Š�f°:Ô	>€B÷ ÐÜ�y‰y×%Ñ%×'Ó'¬U¯Y©Y×-AÑ-A×-CÒ-CÄ|Ç~Ã~ô ×)Ò)¨%¿	¹	ÈÔTˆGÜ×*Ò*¨6¿)¹)È:ÔVˆHßÜ—[’[ ¨1¡¨r¸qµ[Õ/AÀCÕ/GÈ1Õ.LÈbÐSVÍhÓW�Ü—[’[ ¨A¡°ÀµlÕ0CÀcÕ0IÈQÕ/NÐPRÐUXÕPXÓY‘ð ˜B•h •n¨Õ/°#Õ5�Ø˜B•h •n¨Õ0°3Õ6‘ßð 27¸´�" �	Õ" SÕ(¨AÖ-ÀÀSÅˆBØ28¸1´*�" �
Õ# cÕ)¨QÖ.À"ÀsÅ(‰Bà˜•(˜S•. EÕ)¨CÕ/ˆBØ˜•(˜S•. FÕ*¨SÕ0ˆBßà�U‰U�:ÓˆØ�U‰U�:Óˆä#Ÿkšk¬%¯.ª.¸"¸ÈDÔ*QÐWYÔZ€IØ×Ñ˜Q  1Ó%×/Ñ/°Ó2Ð2r   c                óÔ   € V ^8„  d   QhR\         R\         R\         R\        R\        \        P                  ,          R\        \        P
                  ,          R\        P                  /# )r   Údepthr   r	   r
   r   r   r   r   )r   s   "r   r   r   ¸   sm   € ÷ K6ñ K6ÜðK6äðK6ô ðK6ô !ð	K6ô
 ”U—\‘\Õ"ðK6ô ”E—K‘KÕ ðK6ô ‡\�\ñK6r   c                óœ  € Ve   TM!\         P                  ! ^ VR7      P                  pT;'       d$    V\         P                  \         P                  39   pV'       d   \         P
                  MTp\         P                  ! W$VR7      p	\         P                  ! WVR7      p
\         P                  ! WVR7      pV'       Ed    \         P                  P                  4       '       EgT   \         P                  P                  4       '       g   \        4       '       Ed   \         P                  ! W)P                  VR7      p\         P                  ! WP                  VR7      p\         P                  ! WP                  VR7      p\         P                  ! V^8„  Wœ^,
          ,          R,
          ^,          V	R,          4      p	\         P                  ! V^8„  W­^,
          ,          R,
          ^,          V
R,          4      p
\         P                  ! V^8„  W¾^,
          ,          R,
          ^,          VR,          4      pM‡V^8”  d   W’^,
          ,          R,
          ^,          MV	R,          p	V^8”  d   W¡^,
          ,          R,
          ^,          MV
R,          p
V ^8”  d   W°^,
          ,          R,
          ^,          MVR,          pV'       d4   V	P                  V4      p	V
P                  V4      p
VP                  V4      p\         P                  ! \         P                   ! W¹V
.RR7      RR7      pVP#                  ^ ^^^4      P%                  ^ 4      # )	a±  Generate a (1, D, H, W, 3) grid of (d, x, y) voxel coordinates, in [-1, 1] by default.

``grid = create_meshgrid3d(D, H, W)`` returns the ``(d, x, y)`` coordinates of every voxel of a ``D x H x W`` volume
as a ``(1, D, H, W, 3)`` tensor, ``grid[0, k, i, j]`` holding depth ``k``, column ``j`` and row ``i``: normalized
to :math:`[-1, 1]`, corner-aligned, by default, or in voxels with ``normalized_coordinates=False``. Depth comes
first, unlike the ``(x, y, z)`` that :func:`torch.nn.functional.grid_sample` reads. For the ``(1, H, W, 2)`` grid of
an image, use :func:`create_meshgrid`.

Convention:
    - Coordinates follow :ref:`Coordinates and sizes <coordinate-conventions>`. A normalized grid is always
      corner-aligned; reorder its last axis with ``grid[..., [1, 2, 0]]`` before passing it to
      :py:func:`torch.nn.functional.grid_sample`.
    - A size-1 axis is ``0`` and a size-0 axis gives an empty grid.
    - Known defect: there is no ``align_corners`` argument, so the half-pixel grid that
      ``grid_sample(..., align_corners=False)`` expects cannot be requested
      (`#4503 <https://github.com/kornia/kornia/issues/4503>`_).

Args:
    depth: the volume depth (the ``D`` axis).
    height: the image height (rows).
    width: the image width (cols).
    normalized_coordinates: whether to normalize coordinates to :math:`[-1, 1]`.
    device: the device on which the grid will be generated.
    dtype: the data type of the generated grid.

Return:
    grid tensor with shape ``(1, D, H, W, 3)``.

See Also:
    - :func:`create_meshgrid`: the ``(1, H, W, 2)`` grid of ``(x, y)`` pixel coordinates, with an
      ``align_corners`` choice.
    - :func:`~kornia.geometry.conversions.normalize_pixel_coordinates3d`: normalizes given ``(d, x, y)`` voxel
      coordinates the way this grid is normalized.
    - :func:`~kornia.geometry.transform.warp_grid3d`: applies ``4 x 4`` homographies to an ``(x, y, z)`` grid, so
      reorder this one first.

r   r   r   r   r   r   r    r"   r#   )r<   r   r	   r
   r   r   r3   r4   r5   r6   r7   Úzsr8   r9   Údepth_tr:   s   &&&&&&          r   r   r   ¸   sI  € ð`  Ò+‘´·²¸QÀvÔ1N×1TÑ1T€Jð %×VÐV¨¼¿¹ÄuÇ~Á~Ð7VÑ)V€Gß")”—’¨z€JÜ	�Š�e°*Ô	=€BÜ	�Š�f°:Ô	>€BÜ	�Š�e°*Ô	=€BçÐÜ�y‰y×%Ñ%×'Ó'¬U¯Y©Y×-AÑ-A×-CÒ-CÄ|Ç~Ã~Ü×)Ò)¨%¿	¹	ÈÔTˆGÜ×*Ò*¨6¿)¹)È:ÔVˆHÜ×)Ò)¨%¿	¹	ÈÔTˆGÜ—’˜W q™[¨2¸1µÕ+=ÀÕ+CÀqÕ*HÈ"ÈsÍ(ÓSˆBÜ—’˜X¨™\¨B¸Qµ,Õ,?À#Õ,EÈÕ+JÈBÐQTÍHÓUˆBÜ—’˜W q™[¨2¸1µÕ+=ÀÕ+CÀqÕ*HÈ"ÈsÍ(ÓS‰Bà16¸´�" �	Õ" SÕ(¨AÖ-ÀÀSÅˆBØ28¸1´*�" �
Õ# cÕ)¨QÖ.À"ÀsÅ(ˆBØ16¸´�" �	Õ" SÕ(¨AÖ-ÀÀSÅˆBßØ�U‰U�:ÓˆØ�U‰U�:ÓˆØ�U‰U�:Óˆä—’œEŸNšN¨B°B¨<À$ÔGÈRÔP€IØ×Ñ˜Q  1 aÓ(×2Ñ2°1Ó5Ð5r   )TNNT)TNN)	Ú__doc__Útypingr   r   Úkornia.core.utilsr   Ú__all__r   r   © r   r   Ú<module>rE      s3   ðñ$õ ã å *àÐ1Ð
2€÷K3÷\K6ñ K6r   