def make_grad_fn(clf):
  """Return a function which takes the gradient of a loss.

  Args:
    clf (Classifier): the classifier whose gradient we are interested in.
  Returns:
    f (function): a function which takes a scalar loss and GradientTape and
                  returns the gradient of loss w.r.t clf.weights.
  """
  def f(loss, tape):
    return tape.gradient(loss, clf.weights)
  return f