class_docstr: Step sampler on a sampling path.
docstr: Set gradient function.
docstr_tok: ["Set","gradient","function","."]
code: def set_gradient(self, grad_function):
      """Set gradient function."""
      print("set gradient function to %s" % grad_function.__name__)
  
      def plot_gradient_wrapper(x, plot=False):
          """wrapper that makes plots (when desired)"""
          v = grad_function(x)
          if plot:
              plt.plot(x[0], x[1], "+ ", color="k", ms=10)
              plt.plot(
                  [x[0], v[0] * 1e-2 + x[0]],
                  [x[1], v[1] * 1e-2 + x[1]],
                  color="gray",
              )
          return v
  
      self.grad_function = plot_gradient_wrapper
  
imports: import numpy
  import matplotlib.pyplot
  from ultranest.samplingpath import SamplingPath, ContourSamplingPath, extrapolate_ahead
  from ultranest.stepsampler import StepSampler
  from ultranest.stepsampler import generate_region_oriented_direction, generate_region_random_direction, generate_random_direction
  from ultranest.flatnuts import ClockedStepSampler, ClockedBisectSampler, ClockedNUTSSampler
  from ultranest.flatnuts import SingleJumper, DirectJumper, IntervalJumper
label_desc: Use image node_id 6 for calling the SamplingPathStepSampler obj's underlying member method code with example usage: obj.set_gradient(grad_function) and returns: v