code: def resolve_module_dir(module_dir_str, create_new=False):
      """
      Interpret `module_dir_str` as an absolute folder path.
      create the folder if `create_new`
  
      :param module_dir_str:
      :param create_new:
      :return:
      """
      try:
          # interpret input as a module string
          module_from_string = importlib.import_module(module_dir_str)
          folder_path = os.path.dirname(module_from_string.__file__)
          return os.path.abspath(folder_path)
      except (ImportError, AttributeError, TypeError):
          pass
  
      try:
          # interpret last part of input as a module string
          string_last_part = module_dir_str.rsplit(".", 1)
          module_from_string = importlib.import_module(
              string_last_part[-1]
          )
          folder_path = os.path.dirname(module_from_string.__file__)
          return os.path.abspath(folder_path)
      except (ImportError, AttributeError, IndexError, TypeError):
          pass
  
      module_dir_str = os.path.expanduser(module_dir_str)
      try:
          # interpret input as a file folder path string
          if os.path.isdir(module_dir_str):
              return os.path.abspath(module_dir_str)
      except TypeError:
          pass
  
      try:
          # interpret input as a file path string
          if os.path.isfile(module_dir_str):
              return os.path.abspath(os.path.dirname(module_dir_str))
      except TypeError:
          pass
  
      try:
          # interpret input as a path string relative to the global home
          home_location = (
              NiftyNetGlobalConfig().get_niftynet_home_folder()
          )
          possible_dir = os.path.join(home_location, module_dir_str)
          if os.path.isdir(possible_dir):
              return os.path.abspath(possible_dir)
      except (TypeError, ImportError, AttributeError):
          pass
  
      if create_new:
          # try to create the folder
          folder_path = touch_folder(module_dir_str)
          init_file = os.path.join(folder_path, "__init__.py")
          try:
              file_ = os.open(
                  init_file, os.O_CREAT | os.O_EXCL | os.O_WRONLY
              )
          except OSError as sys_error:
              if sys_error.errno == errno.EEXIST:
                  pass
              else:
                  tf.logging.fatal(
                      "trying to use '{}' as NiftyNet writing path, "
                      "however cannot write '{}'".format(
                          folder_path, init_file
                      )
                  )
                  raise
          else:
              with os.fdopen(file_, "w") as file_object:
                  file_object.write("# Created automatically\n")
          return folder_path
      raise ValueError(
          "Could not resolve [{}].\nMake sure it is a valid folder path "
          "or a module name.\nIf it is string representing a module, "
          "the parent folder of [{}] should be on "
          "the system path.\n\nCurrent system path {}.".format(
              module_dir_str, module_dir_str, sys.path
          )
      )
  
imports: from __future__ import absolute_import, print_function, unicode_literals
  import errno
  import importlib
  import logging
  import os
  import re
  import sys
  import warnings
  import nibabel
  import numpy
  import pandas
  import scipy.ndimage
  import tensorflow
  from tensorflow.core.framework import summary_pb2
  from niftynet.io.image_loader import load_image_obj
  from niftynet.utilities.niftynet_global_config import NiftyNetGlobalConfig
  from niftynet.utilities.util_import import require_module
label_desc: Use image node_id 18 for calling a global function with example usage: resolve_module_dir(module_dir_str, create_new) and returns: os, os, folder_path, os, os, os