code: def gradient_image(ax, direction=0.3, cmap_range=(0, 1), **kwargs):
      """
      Draw a gradient image based on a colormap.
  
      Parameters
      ----------
      ax : Axes
          The Axes to draw on.
      direction : float
          The direction of the gradient. This is a number in
          range 0 (=vertical) to 1 (=horizontal).
      cmap_range : float, float
          The fraction (cmin, cmax) of the colormap that should be
          used for the gradient, where the complete colormap is (0, 1).
      **kwargs
          Other parameters are passed on to `.Axes.imshow()`.
          In particular, *cmap*, *extent*, and *transform* may be useful.
      """
      phi = direction * np.pi / 2
      v = np.array([np.cos(phi), np.sin(phi)])
      X = np.array([[v @ [1, 0], v @ [1, 1]], [v @ [0, 0], v @ [0, 1]]])
      a, b = cmap_range
      X = a + (b - a) / X.max() * X
      im = ax.imshow(
          X,
          interpolation="bicubic",
          clim=(0, 1),
          aspect="auto",
          **kwargs,
      )
      return im
  
imports: import matplotlib.pyplot
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: gradient_image(ax, direction, cmap_range) and returns: im