
    3jt                         S SK r S SKJs  Jr  S SKJrJr   S
S\ R                  S\	S\ R                  S\ R                  S\S\ R                  4S	 jjrg)    N)KORNIA_CHECKKORNIA_CHECK_IS_TENSORlabelsnum_classesdevicedtypeepsreturnc                 v   [        U S5        [        U R                  [        R                  :H  SU R                   35        [        US:  SU 35        [
        R                  " XS9nU R                  nS/U/-   [        [        SU5      5      -   nUR                  " U6 nUR                  X2S9nUSU-
  -  U-   nU$ )	a  Convert an integer label x-D torch.Tensor to a one-hot (x+1)-D torch.Tensor.

Args:
    labels: torch.Tensor with labels of shape :math:`(N, *)`, where N is batch size.
      Each value is an integer representing correct classification.
    num_classes: number of classes in labels.
    device: the desired device of returned torch.Tensor.
    dtype: the desired data type of returned torch.Tensor.
    eps: epsilon for numerical stability.

Returns:
    the labels in one hot torch.Tensor of shape :math:`(N, C, *)`,

Examples:
    >>> labels = torch.LongTensor([[[0, 1], [2, 0]]])
    >>> one_hot(labels, num_classes=3, device=torch.device('cpu'), dtype=torch.float32)
    tensor([[[[1.0000e+00, 1.0000e-06],
              [1.0000e-06, 1.0000e+00]],
    <BLANKLINE>
             [[1.0000e-06, 1.0000e+00],
              [1.0000e-06, 1.0000e-06]],
    <BLANKLINE>
             [[1.0000e-06, 1.0000e-06],
              [1.0000e+00, 1.0000e-06]]]])

z#Input labels must be a torch.Tensorz*labels must be of dtype torch.int64. Got:    z)The number of classes must be >= 1. Got: )r   r   )r   r   g      ?)r   r   r   torchint64Fone_hotndimlistrangepermuteto)r   r   r   r   r	   one_hot_tensorr   permute_dimss           O/home/wildlama/miniconda3/lib/python3.13/site-packages/kornia/losses/one_hot.pyr   r      s    : 6#HI,0Z[a[g[gZh.ij!%N{m#\] YYv?N
 ;;D3$<$uQ~"66L#++\:N $&&U&BN#sSy1C7N    )gư>)r   torch.nn.functionalnn
functionalr   kornia.core.checkr   r   Tensorintr   r   floatr    r   r   <module>r"      s_   $    B dh0LL0'*049LL0IN0[`0
\\0r   