outputs_[i]->uses().empty()INTERNAL ASSERT FAILED at "/opt/conda/conda-bld/pytorch_1646755853042/work/torch/csrc/jit/ir/ir.cpp":1314, please report a bug to PyTorch. 
Labels: oncall: jit

### 🐛 Describe the bug

When I use torch.jit.script for the class, in the line  p = pt_2d[b, :, pix2pt] it will pop up the issue descriped in the title. The snippet :
```python
import math
import torch
import torch.nn as nn

class DifferentiableRasterizer(nn.Module):

    def __init__(self,face,height,width,block_size=32):

        super(DifferentiableRasterizer, self).__init__()

        self.block_size = block_size
        self.width = width
        self.height = height
        self.width_exp = int(math.ceil(float(width)/float(self.block_size)))*self.block_size
        self.height_exp = int(math.ceil(float(height)/float(self.block_size)))*self.block_size
        self.face = face
        self.index_buf = torch.full((self.height_exp, self.width_exp), face.shape[1], dtype=torch.long).to(face.device)
        self.face_index = torch.LongTensor(range(0,self.face.shape[1])).to(face.device)

        self.x_grid = torch.tensor(range(0,self.width)).unsqueeze(0).to(face.device)
        self.y_grid = torch.tensor(range(0,self.height)).unsqueeze(1).to(face.device)
        self.x_grid_block = torch.tensor(range(0,self.block_size)).unsqueeze(0).unsqueeze(2).to(face.device)
        self.y_grid_block = torch.tensor(range(0,self.block_size)).unsqueeze(1).unsqueeze(2).to(face.device)

    def forward(self,pt_2d,color,pt_3d,normal,R,T):


        ftiny = 1.17e-35
        inf_value = 3.40e+35
        lower_inf_value = 3.40e+34
        
        batch, vnum, pnum = pt_2d.shape
        cnum = color.shape[1]

        image = torch.zeros(batch,cnum,self.height,self.width,device=pt_2d.device)
        mask = torch.zeros(batch,self.height,self.width,device=pt_2d.device)

        for b in range(batch):
            with torch.no_grad():

                norm_cul = torch.sum((pt_3d[b,:,self.face[0, :]] + (R[b,:,:].t()@T[b,:, :])) * normal[b,:,:],0) < 0
                depth_cul = torch.min(pt_2d[b,2,self.face], 0)[0] > 0

                if torch.sum(norm_cul * depth_cul).item()==0:
                    continue

                face_red = self.face[:, norm_cul * depth_cul]
                face_index_red = self.face_index[norm_cul * depth_cul]
                num = face_red.shape[1]

                self.index_buf[:] = num

                p = pt_2d[b, :, face_red]

                pz_min,_ = torch.min(p[2,:,:],0)
                px_min,_ = torch.min(p[0,:,:].int(),0)
                px_max,_ = torch.max(p[0,:,:].int(),0)
                py_min,_= torch.min(p[1, :, :].int(), 0)
                py_max,_ = torch.max(p[1,:,:].int(),0)
                x_min,_ = torch.min(px_min,0)
                x_max,_ = torch.max(px_max,0)
                y_min,_ = torch.min(py_min,0)
                y_max,_ = torch.max(py_max,0)

                range_x_min = max(x_min.item()-x_min.item()%self.block_size,0)
                range_y_min = max(y_min.item() - y_min.item() % self.block_size, 0)
                range_x_max = min(x_max.item(), self.width_exp)
                range_y_max = min(y_max.item(), self.height_exp)

                det = ((p[1, 1, :] - p[1, 2, :]) * (p[0, 0, :] - p[0, 2, :]) + (p[0, 2, :] - p[0, 1, :]) * (p[1, 0, :] - p[1, 2, :])).unsqueeze(0).unsqueeze(0)
                det = det.sign()*torch.clamp(det.abs(),min=ftiny)
                inv_det = 1/det

                l0_x = (p[1, 1, :] - p[1, 2, :]) * inv_det
                l0_y = (p[0, 2, :] - p[0, 1, :]) * inv_det
                l0_c = -l0_x*p[0, 2, :] - l0_y *p[1, 2, :]

                l1_x = (p[1, 2, :] - p[1, 0, :]) * inv_det
                l1_y = (p[0, 0, :] - p[0, 2, :]) * inv_det
                l1_c = -l1_x*p[0, 2, :] - l1_y *p[1, 2, :]

                l2_x = -l0_x - l1_x
                l2_y = -l0_y - l1_y
                l2_c = 1-l0_c-l1_c

                p = p.unsqueeze(1).unsqueeze(1)
                D_x = p[2, :, :, 0, :] * l0_x + p[2, :, :, 1, :] * l1_x + p[2, :, :, 2, :] * l2_x
                D_y = p[2, :, :, 0, :] * l0_y + p[2, :, :, 1, :] * l1_y + p[2, :, :, 2, :] * l2_y
                D_c = (p[2,:,:,0,:]*l0_c + p[2,:,:,1,:]*l1_c + p[2,:,:,2,:]*l2_c)

                for i in range(int(range_y_min),int(range_y_max),int(self.block_size)):

                    D_yc = D_y * (float(i)+self.y_grid_block) + D_c
                    l0_yc = l0_y * (float(i) + self.y_grid_block) + l0_c
                    l1_yc = l1_y * (float(i) + self.y_grid_block) + l1_c
                    l2_yc = l2_y * (float(i) + self.y_grid_block) + l2_c

                    for k in range(int(range_x_min),int(range_x_max),int(self.block_size)):

                        target = (px_max>=k)*(px_min<k+self.block_size)*(py_max>=i)*(py_min<i+self.block_size)

                        face_ct = torch.sum(target, 0, dtype=torch.long)
                        if face_ct == 0:
                            continue

                        kxg = float(-k)-self.x_grid_block

                        M = (l0_yc[:,:,target]  >= (l0_x[:,:,target]* kxg)) * (l1_yc[:,:,target]  >= (l1_x[:,:,target]* kxg)) * (l2_yc[:,:,target] >= (l2_x[:,:,target]* kxg))

                        vis_ct = torch.max(torch.sum(M, 2)).item()

                        if vis_ct==1:
                            vis, idx = torch.max(M, 2)
                            self.index_buf[i:i + self.block_size, k:k + self.block_size][vis] = (self.face_index[0:target.shape[0]][target])[idx[vis]]

                        elif vis_ct>1:
                            D = M.bitwise_not().float() * inf_value + D_x[:,:,target] * (float(k)+self.x_grid_block) + D_yc[:,:,target]
                            D[D!=D]=inf_value
                            depth, idx = torch.min(D,2)
                            vis = depth< lower_inf_value

                            self.index_buf[i:i+self.block_size, k:k+self.block_size][vis] = (self.face_index[0:target.shape[0]][target])[idx[vis]]

                mask_ = (self.index_buf[0:self.height,0:self.width]!=num).float()
                index_buf_tmp = self.index_buf[0:self.height,0:self.width]
                index_buf_tmp[index_buf_tmp==num] = 0
                pix2pt = self.face[:,face_index_red[index_buf_tmp]]
            
            p = pt_2d[b, :, pix2pt] 

face = torch.randint(1,100, (3, 20))
traced_script_module = torch.jit.script(DifferentiableRasterizer(face,224,224,32))
```

# the error occur in the last line     p = pt_2d[b, :, pix2pt] 


### Versions

Versions of relevant libraries:
[pip3] facenet-pytorch==2.5.2
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.20.1
[pip3] numpydoc==1.1.0
[pip3] pytorch3d==0.6.1
[pip3] torch==1.11.0
[pip3] torchaudio==0.11.0
[pip3] torchvision==0.12.0
[conda] blas                      1.0                         mkl
[conda] cudatoolkit               10.2.89              hfd86e86_1
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2021.2.0           h06a4308_296
[conda] mkl-service               2.3.0            py38h27cfd23_1
[conda] mkl_fft                   1.3.0            py38h42c9631_2
[conda] mkl_random                1.2.1            py38ha9443f7_2
[conda] numpy                     1.20.1           py38h93e21f0_0
[conda] numpy-base                1.20.1           py38h7d8b39e_0
[conda] numpydoc                  1.1.0              pyhd3eb1b0_1
[conda] pytorch                   1.11.0          py3.8_cuda10.2_cudnn7.6.5_0                                                                                                                 pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] pytorch3d                 0.6.1           py38_cu102_pyt1110    pytorch3                                                                                                             d-nightly
[conda] torchaudio                0.11.0               py38_cu102    pytorch
[conda] torchvision               0.12.0               py38_cu102    pytorch