Repository: pytorch
Issue: Functorch does not work with CrossEntropyLoss and label=-100
Labels: triaged,actionable,module: functorch

### 🐛 Describe the bug

The following code triggers index out of bound exception (for '-100'), but '-100' is the value of `ignore_index`.
Below is a minimal reproducing example
```python
import torch
from functorch import grad_and_value, vmap, make_functional_with_buffers
import torch.nn as nn


model = nn.Linear(10, 10)
fmodel, _fparams, buffers = make_functional_with_buffers(model)

criterion = nn.CrossEntropyLoss(reduction="mean")
def compute_loss_stateless_model(params, buffers, sample, target):
    batch = sample.unsqueeze(0)
    targets = target.unsqueeze(0)

    predictions = fmodel(params, buffers, batch)
    loss = criterion(predictions, targets)

    return loss

ft_compute_grad = grad_and_value(compute_loss_stateless_model)
ft_compute_sample_grad = vmap(ft_compute_grad, in_dims=(None, None, 0, 0))
params = list(model.parameters())

B = 256
T = 64
D = 10
inputs = torch.randn(B, D)
targets = torch.randint(0, D, (B,))

targets[1] = -100
grads, losses = ft_compute_sample_grad(params, buffers, inputs, targets)
```

### Versions

Collecting environment information...
PyTorch version: 1.13.0
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.4 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.16.3
Libc version: glibc-2.31

Python version: 3.9.13 (main, Oct 13 2022, 21:15:33)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.4.0-124-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 11.0.221
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: Quadro GP100
GPU 1: Quadro GP100

Nvidia driver version: 470.141.03
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] functorch==1.13.0
[pip3] numpy==1.23.3
[pip3] torch==1.13.0
[pip3] torchaudio==0.13.0
[pip3] torchvision==0.14.0
[conda] blas                      1.0                         mkl
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] functorch                 1.13.0                   pypi_0    pypi
[conda] mkl                       2021.4.0           h06a4308_640
[conda] mkl-service               2.4.0            py39h7f8727e_0
[conda] mkl_fft                   1.3.1            py39hd3c417c_0
[conda] mkl_random                1.2.2            py39h51133e4_0
[conda] numpy                     1.23.3           py39h14f4228_1
[conda] numpy-base                1.23.3           py39h31eccc5_1
[conda] pytorch                   1.13.0          py3.9_cuda11.6_cudnn8.3.2_0    pytorch
[conda] pytorch-cuda              11.6                 h867d48c_0    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torchaudio                0.13.0               py39_cu116    pytorch
[conda] torchvision               0.14.0               py39_cu116    pytorch

cc @zou3519 @Chillee @samdow @soumith