Oh I get it, another thing please, in this code
import torch
depth  = torch.randn((22000,3), requires_grad= True)
depth[depth<0].zero_()

rot_sin = torch.sin(torch.FloatTensor([0.4]))
rot_cos = torch.cos(torch.FloatTensor([0.4]))
rot_mat_T = torch.FloatTensor(
            [[rot_cos, 0, -rot_sin], [0, 1, 0], [rot_sin, 0, rot_cos]],
        )
rot_mat_T.requires_grad = True
depth = depth @ rot_mat_T

linear = torch.nn.Linear(3,4)
out = linear(depth)
out.sum().backward(retain_graph =True)
print(depth.grad)

It gives me this warning
UserWarning: The .grad attribute of a Tensor that is not a leaf Tensor is being accessed. Its .grad attribute won't be populated during autograd.backward(). If you indeed want the gradient for a non-leaf Tensor, use .retain_grad() on the non-leaf Tensor. If you access the non-leaf Tensor by mistake, make sure you access the leaf Tensor instead. See github.com/pytorch/pytorch/pull/30531 for more informations.
  print(depth.grad)

put if I replaced this line depth = depth @ rot_mat_T with new_depth = depth @ rot_mat_T
and out = linear(depth) to out = linear(new_depth) it works and print the gradient, why is that?