
    3j=                        S SK Jr  S SKr   SS\S\S\S\\R
                     S\\R                     S\R                  4S	 jjr   SS
\S\S\S\S\\R
                     S\\R                     S\R                  4S jjr	g)    )OptionalNheightwidthnormalized_coordinatesdevicedtypereturnc                 B   [         R                  " SUS-
  XUS9n[         R                  " SU S-
  XUS9nU(       a  XQS-
  -  S-
  S-  nX`S-
  -  S-
  S-  n[         R                  " [         R                  " XV/SS9SS	9nUR	                  SSS5      R                  S5      $ )
a  Generate a coordinate grid for an image.

When the flag ``normalized_coordinates`` is set to True, the grid is
normalized to be in the range :math:`[-1,1]` to be consistent with the pytorch
function :py:func:`torch.nn.functional.grid_sample`.

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.

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

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

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

r      r   r         ?   ijindexingdimtorchlinspacestackmeshgridpermute	unsqueeze)r   r   r   r   r   xsys	base_grids           N/home/wildlama/miniconda3/lib/python3.13/site-packages/kornia/geometry/grid.pycreate_meshgridr       s    R ~~aEPUVB~~a!VRWXB AI$)QJ#%* $kk%.."D*QWYZIQ1%//22    depthc                    [         R                  " SUS-
  X$US9n[         R                  " SUS-
  XUS9n[         R                  " SU S-
  XUS9nU(       a'  XbS-
  -  S-
  S-  nXqS-
  -  S-
  S-  nXS-
  -  S-
  S-  n[         R                  " [         R                  " XU/SS9SS	9n	U	R	                  SSSS
5      R                  S5      $ )a  Generate a coordinate grid for an image.

When the flag ``normalized_coordinates`` is set to True, the grid is
normalized to be in the range :math:`[-1,1]` to be consistent with the pytorch
function :py:func:`torch.nn.functional.grid_sample`.

Args:
    depth: the image depth (channels).
    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.

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

r   r   r   r   r   r   r   r   r      r   )
r"   r   r   r   r   r   r   r   zsr   s
             r   create_meshgrid3dr&   X   s    8 ~~aEPUVB~~a!VRWXB~~aEPUVBAI$)QJ#%*AI$)ENNBB<$GRPIQ1a(22155r!   )TNN)
typingr   r   intboolr   r   Tensorr    r&    r!   r   <module>r,      s   &   $(%)#'=3=3=3 !=3 U\\"	=3
 EKK =3 \\=3H $(%)#'&6&6&6 &6 !	&6
 U\\"&6 EKK &6 \\&6r!   