code: def init_matplotlib_backend(backend=None):
      
  
      import matplotlib
  
      try:
          os.environ['DISPLAY']
      except KeyError:
          matplotlib.use('Agg')
      else:
          if backend is not None:
              matplotlib.use(backend)
docs: This function initializes the matplotlib backend.  When no
      DISPLAY is available the backend is automatically set to 'Agg'.
  
      Parameters
      ----------
      backend : str
         matplotlib backend name.