I written 2 code for torch.where() as below. In first code it print “require_grad” True but in Second code when i write same in “torch.autograd.Function” it shows “require_grad” False. Why the behavior is different?

First Code:
import torch
a=torch.zeros([1,5,5,10],device=0,requires_grad=True)
b=torch.tensor([3],device=0, dtype=torch.float, requires_grad=True)
c=torch.tensor([4],device=0, dtype=torch.float, requires_grad=True)
d=torch.where(a>200,b,c)
print(" d grad is ",d.requires_grad)


Second Code:
class fun_c(torch.autograd.Function):
@staticmethod
def forward(cxt,input):
a=torch.zeros([1,5,5,10],device=0,requires_grad=True)
a=torch.tensor([3],device=0, dtype=torch.float, requires_grad=True)
b=torch.tensor([4],device=0, dtype=torch.float, requires_grad=True)
d=torch.where(a>200,b,c)
print(" d grad is ",d.requires_grad)
return d
@staticmethod
def backward(ctx, grad_output):
input, = ctx.saved_tensors
grad_input = grad_output.clone()
grad_input[input < 0] = 0
return grad_input
hist=fun_c.apply
a=hist(2)