code: def plot_weights(
      weight_img,
      background_img=None,
      color_marker_pos="rs",
      color_marker_neg="gs",
      im_kwargs=None,
      marker_kwargs=None,
  ):
      """Visualize model weights
  
      Args:
          weight_img (array-like): Model weight/coefficients in 2D, could be a 2D slice of a 3D or higher order tensor.
          background_img (array-like, optional): 2D background image. Defaults to None.
          color_marker_pos (str, optional): Color and marker for weights in positive values. Defaults to red "rs".
          color_marker_neg (str, optional): Color and marker for weights in negative values. Defaults to blue "gs".
          im_kwargs (dict, optional): Keyword arguments for background images. Defaults to None.
          marker_kwargs (dict, optional): Keyword arguments for background images. Defaults to None.
  
      Returns:
          [matplotlib.figure.Figure]: Figure to plot.
      """
      if not isinstance(weight_img, np.ndarray):
          weight_img = np.array(weight_img)
      if len(weight_img.shape) != 2:
          raise ValueError(
              "weight_img is expected to be a 2D matrix, but got an array in shape %s"
              % str(weight_img.shape)
          )
      im_kwargs = _none2dict(im_kwargs)
      marker_kwargs = _none2dict(marker_kwargs)
      fig = plt.figure()
      ax = fig.add_subplot()
      if background_img is not None:
          ax.imshow(background_img, **im_kwargs)
          weight_img[np.where(background_img == 0)] = 0
  
      weight_pos_coords = np.where(weight_img > 0)
      weight_neg_coords = np.where(weight_img < 0)
  
      ax.plot(
          weight_pos_coords[1],
          weight_pos_coords[0],
          color_marker_pos,
          **marker_kwargs,
      )
      ax.plot(
          weight_neg_coords[1],
          weight_neg_coords[0],
          color_marker_neg,
          **marker_kwargs,
      )
  
      return fig
  
imports: import matplotlib.pyplot
  import numpy
  import seaborn
label_desc: Use image node_id 2 for calling a global function with example usage: plot_weights(weight_img, background_img, color_marker_pos, color_marker_neg, im_kwargs, marker_kwargs) and returns: fig