def model_grads_to_master_grads(model_params, master_params):
    """
    Copy the gradients from the model parameters into the master parameters
    from make_master_params().
    """
    master_params[0].grad = _flatten_dense_tensors(
        [param.grad.data.detach().float() for param in model_params]
    )

    Copy the gradients from the model parameters into the master parameters
    from make_master_params().
    
trellis/trainers/utils.py