Sure, the only thing that happens before the given code is
if flag:
    with torch.no_grad():
        outputs = main_model(tensor)
else:
    outputs = main_model(tensor)

SOME_TENSORS = outputs
if flag:
    SOME_TENSORS.requires_grad_() # also tried SOME_TENSORS.requires_grad = True

and after the given code:
# checking here gives None gradients
loss = metric(final_result, labels)
loss.backward()
# checking here gives None gradients
optimiser.step()

Even if x was set without requires_grad, shouldn’t var2 get updated? If not, could you explain why not?