Returns a list of trainable parameters in the model m. (i.e., those that require gradients.)

def trainable_params_(m):
    """ Returns a list of trainable parameters in the model m. (i.e., those that require gradients.) """
    if isinstance(m, collections.Sequence):
        return [p for p in m if p.requires_grad]
    else:
        return [p for p in m.parameters() if p.requires_grad]