def zero_grad(model):
    """ set gradient of model to zero without having to use an optimizer object """
    for param in model.parameters():
        if param.grad is not None:
            param.grad.detach_()
            param.grad.zero_()
