Are these two equivalent?
import torch, torch.nn as nn
loss_fn = nn.CrossEntropyLoss()
scores = torch.randn(1, 10,requires_grad=True)
y_a_i = torch.tensor([5])
lin = nn.Linear(10, 10)
set_loss = loss_fn(lin(scores), y_a_i) 
fast_parameters = list(lin.parameters())
grad = torch.autograd.grad(set_loss, fast_parameters, create_graph=True) 
grad = [g.detach() for g in grad]

import torch, torch.nn as nn
loss_fn = nn.CrossEntropyLoss()
scores = torch.randn(1, 10,requires_grad=True)
y_a_i = torch.tensor([5])
lin = nn.Linear(10, 10)
set_loss = loss_fn(lin(scores), y_a_i) 
fast_parameters = list(lin.parameters())
grad = torch.autograd.grad(set_loss, fast_parameters, create_graph=False)