code: def _image_directories(func):
      """
      Compute the baseline and result image directories for testing *func*.
      Create the result directory if it doesn't exist.
      """
      module_name = func.__module__
      if module_name == "__main__":
          # FIXME: this won't work for nested packages in matplotlib.tests
          warnings.warn(
              "Test module run as script. Guessing baseline image locations."
          )
          script_name = sys.argv[0]
          basedir = os.path.abspath(os.path.dirname(script_name))
          subdir = os.path.splitext(os.path.split(script_name)[1])[0]
      else:
          mods = module_name.split(".")
          if len(mods) >= 3:
              mods.pop(0)
              # mods[0] will be the name of the package being tested (in
              # most cases "matplotlib") However if this is a
              # namespace package pip installed and run via the nose
              # multiprocess plugin or as a specific test this may be
              # missing. See https://github.com/matplotlib/matplotlib/issues/3314
          if mods.pop(0) != "tests":
              warnings.warn(
                  "Module {!r} does not live in a parent module named 'tests'. "
                  "This is probably ok, but we may not be able to guess the "
                  "correct subdirectory containing the baseline images. If "
                  "things go wrong please make sure that there is a parent "
                  "directory named 'tests' and that it contains a __init__.py "
                  "file (can be empty).".format(module_name)
              )
          subdir = os.path.join(*mods)
  
          import imp
  
          def find_dotted_module(module_name, path=None):
              """A version of imp which can handle dots in the module name.
              As for imp.find_module(), the return value is a 3-element
              tuple (file, pathname, description)."""
              res = None
              for sub_mod in module_name.split("."):
                  try:
                      res = file, path, _ = imp.find_module(
                          sub_mod, path
                      )
                      path = [path]
                      if file is not None:
                          file.close()
                  except ImportError:
                      # assume namespace package
                      path = list(sys.modules[sub_mod].__path__)
                      res = None, path, None
              return res
  
          mod_file = find_dotted_module(func.__module__)[1]
          basedir = os.path.dirname(mod_file)
  
      baseline_dir = os.path.join(basedir, "baseline_images", subdir)
      result_dir = os.path.abspath(
          os.path.join("result_images", subdir)
      )
  
      if not os.path.exists(result_dir):
          cbook.mkdirs(result_dir)
  
      return baseline_dir, result_dir
  
imports: from __future__ import absolute_import, division, print_function
  import six
  import functools
  import inspect
  import os
  import sys
  import shutil
  import warnings
  import unittest
  import matplotlib
  import matplotlib.style
  import matplotlib.units
  import matplotlib.testing
  from matplotlib import cbook
  from matplotlib import ticker
  from matplotlib import pyplot
  from matplotlib import ft2font
  from matplotlib.testing.compare import comparable_formats, compare_images, make_test_filename
  from .None import _copy_metadata, is_called_from_pytest
  from .exceptions import ImageComparisonFailure
label_desc: Use image node_id 13 for calling a global function with example usage: _image_directories(func) and returns: baseline_dir,  result_dir, res