pytorch/torch/nn
zeshengzong 4a545eb85d Fix torch.nn.functional.one_hot param num_classes optional description (#146470)
`torch.nn.functional.one_hot` [document](https://pytorch.org/docs/stable/generated/torch.nn.functional.one_hot.html) describe param `num_classes` not optional, but user can call method without pass it.

![image](https://github.com/user-attachments/assets/4e6d4feb-691f-451f-95b5-4ac11bac7bc2)

```python
>>> import torch
>>> a = torch.arange(0, 5) % 3  # [0,1,2,0,1]
>>> torch.nn.functional.one_hot(a)
tensor([[1, 0, 0],
        [0, 1, 0],
        [0, 0, 1],
        [1, 0, 0],
        [0, 1, 0]])

```

`num_classes` has default value -1

93d98aca31/aten/src/ATen/native/native_functions.yaml (L6154-L6157)

## Test Result

![image](https://github.com/user-attachments/assets/2c7203b7-6226-4ebc-84c8-cbf912fc48e2)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/146470
Approved by: https://github.com/albanD
2025-02-06 07:48:05 +00:00
..
attention Fix a number of flexattention issues (cse, cudagraph, etc.) (#145059) 2025-01-29 20:27:39 +00:00
backends
intrinsic
modules [BE]: Enable ruff SLOT checks (#146276) 2025-02-04 19:18:23 +00:00
parallel
qat
quantizable
quantized
utils torch/nn/utils/rnn.py: docs: improvements (#138628) 2025-02-01 00:10:30 +00:00
__init__.py
_reduction.py
common_types.py
cpp.py
functional.py Fix torch.nn.functional.one_hot param num_classes optional description (#146470) 2025-02-06 07:48:05 +00:00
functional.pyi.in
grad.py
init.py
parameter.py
parameter.pyi