code: def plot2D(
      x,
      my_gmm,
      z=None,
      with_dots=True,
      log_scale=False,
      mpaxes=None,
      verbose=0,
  ):
      """
      Given a set of points in a plane and a GMM, plot them
  
      Parameters
      ----------
      x: array of shape (npoints, dim=2),
          sample points
      my_gmm: GMM instance,
              whose density has to be plotted
      z: array of shape (npoints), optional
         that gives a labelling of the points in x
         by default, it is not taken into account
      with_dots, bool, optional
                 whether to plot the dots or not
      log_scale: bool, optional
                 whether to plot the likelihood in log scale or not
      mpaxes=None, int, optional
                   if not None, axes handle for plotting
      verbose: verbosity mode, optional
  
      Returns
      -------
      gd, GridDescriptor instance,
          that represents the grid used in the function
      ax, handle to the figure axes
  
      Notes
      -----
      ``my_gmm`` is assumed to have have a  'nixture_likelihood' method that takes
      an array of points of shape (np, dim) and returns an array of shape
      (np,my_gmm.k) that represents the likelihood component-wise
      """
      import matplotlib.pyplot as plt
  
      if x.shape[1] != my_gmm.dim:
          raise ValueError(
              "Incompatible dimension between data and model"
          )
      if x.shape[1] != 2:
          raise ValueError("this works only for 2D cases")
  
      gd1 = GridDescriptor(2)
      xmin, xmax = x.min(0), x.max(0)
      xm = 1.1 * xmin[0] - 0.1 * xmax[0]
      xs = 1.1 * xmax[0] - 0.1 * xmin[0]
      ym = 1.1 * xmin[1] - 0.1 * xmax[1]
      ys = 1.1 * xmax[1] - 0.1 * xmin[1]
  
      gd1.set([xm, xs, ym, ys], [51, 51])
      grid = gd1.make_grid()
      L = my_gmm.mixture_likelihood(grid)
      if verbose:
          intl = L.sum() * (xs - xm) * (ys - ym) / 2500
          print("integral of the density on the domain ", intl)
  
      if mpaxes is None:
          plt.figure()
          ax = plt.subplot(1, 1, 1)
      else:
          ax = mpaxes
  
      gdx = gd1.n_bins[0]
      Pdens = np.reshape(L, (gdx, -1))
      extent = [xm, xs, ym, ys]
      if log_scale:
          plt.imshow(np.log(Pdens.T), origin="lower", extent=extent)
      else:
          plt.imshow(Pdens.T, origin="lower", extent=extent)
  
      if with_dots:
          if z is None:
              plt.plot(x[:, 0], x[:, 1], "o")
          else:
              hsv = plt.cm.hsv(list(range(256)))
              col = hsv[:: (256 // int(z.max() + 1))]
              for k in range(z.max() + 1):
                  plt.plot(
                      x[z == k, 0], x[z == k, 1], "o", color=col[k]
                  )
  
      plt.axis(extent)
      plt.colorbar()
      return gd1, ax
  
imports: import numpy
  from scipy.linalg import eigvalsh
label_desc: Use image node_id 2 for calling a global function with example usage: plot2D(x, my_gmm, z, with_dots, log_scale, mpaxes, verbose) and returns: gd1,  ax