I don’t know, which operation is raising this issue, but it could be the indexing of mg_t, in case it has a single dimension as seen here:
mg_t = torch.randn(10)
mg_t[:, None, :, :]
> IndexError: too many indices for tensor of dimension 1