Yeah I checked with the codes below
and none of the grads are set. If so, how can we check that the gradients (or partial derivatives in this case precisely) are calculated for functions outside of the linear layer? (I want to ensure the exact same thing  for my above model)
def forward(model,x):
  model(x)
  print(x.grad)
  x = x**2
  print(x.grad)
  x = x/ 10
  print(x.grad)
  return x
model = nn.Sequential(nn.Linear(10,2), nn.Linear(2,1))
x = torch.randn(10, requires_grad=True)
x = forward(model,x)
loss = torch.norm(x)
loss.backward()
x = forward(model, x)```