MattTrap:

mult = torch.sum(torch.tensor([torch.dot(torch.flatten(x),torch.flatten(y)).item() for x,y in zip(grad,eta)], requires_grad=True))



You are calling .item and also creating a new tensor on this line both of which break the graph.
You can do something like torch.sum(torch.stack([torch.dot(x.flatten(), y.flatten()) for x, y in zip(grad, eta)])) which should preserve the graph