confirmed the shape of grads [‘dl / df’].
The shape was [1,6]. Since the shape of y was [6], grads [‘dl / df’] = torch.squeeze (grads [‘dl / df’], dim = 0) was executed.
Thanks to your advice, this index error has been fixed.