code: def save_figs(request):
      """Enable command line switch for saving generation figures upon testing."""
      fig_dir = request.config.getoption("--save")
  
      if fig_dir is not None:
          # Try creating directory if it doesn't exist
          _log.info("Saving generated images in %s", fig_dir)
  
          os.makedirs(fig_dir, exist_ok=True)
          _log.info("Directory %s created", fig_dir)
  
          # Clear all files from the directory
          # Does not alter or delete directories
          for file in os.listdir(fig_dir):
              full_path = os.path.join(fig_dir, file)
  
              try:
                  os.remove(full_path)
  
              except OSError:
                  _log.info("Failed to remove %s", full_path)
  
      return fig_dir
  
imports: import logging
  import os
  import numpy
  import pytest
label_desc: Use image node_id 3 for calling a global function with example usage: save_figs(request) and returns: fig_dir