code: def create_mpl_ax(ax=None):
      """Helper function for when a single plot axis is needed.
  
      Parameters
      ----------
      ax : AxesSubplot, optional
          If given, this subplot is used to plot in instead of a new figure being
          created.
  
      Returns
      -------
      fig : Figure
          If `ax` is None, the created figure.  Otherwise the figure to which
          `ax` is connected.
      ax : AxesSubplot
          The created axis if `ax` is None, otherwise the axis that was passed
          in.
  
      Notes
      -----
      This function imports `matplotlib.pyplot`, which should only be done to
      create (a) figure(s) with ``plt.figure``.  All other functionality exposed
      by the pyplot module can and should be imported directly from its
      Matplotlib module.
  
      See Also
      --------
      create_mpl_fig
  
      Examples
      --------
      A plotting function has a keyword ``ax=None``.  Then calls:
  
      >>> from statsmodels.graphics import utils
      >>> fig, ax = utils.create_mpl_ax(ax)
      """
      if ax is None:
          plt = _import_mpl()
          fig = plt.figure()
          ax = fig.add_subplot(111)
      else:
          fig = ax.figure
  
      return fig, ax
  
imports: from statsmodels.compat.python import lrange
label_desc: Use image node_id 2 for calling a global function with example usage: create_mpl_ax(ax) and returns: fig,  ax