def dgamma_dt(en, p, m):
    """
    Args:
            en (torch.Tensor): energy tensor of dimension N_J
            p (torch.Tensor): a momentum tensor of dimension N_J x N_at x 3
            m (torch.Tensor): a mass tensor of dimension N_at
    Returns:
            deriv (torch.Tensor): derivative of gamma, a tensor of dimension
                    N_J.
    """

    reshape_m = m.reshape(1, -1, 1)
    deriv = -en + (p ** 2 / (2 * reshape_m)).sum((1, 2))

    return deriv