code: def get_subjects_dir(subjects_dir=None, raise_error=False):
      """Safely use subjects_dir input to return SUBJECTS_DIR.
  
      Parameters
      ----------
      subjects_dir : path-like | None
          If a value is provided, return subjects_dir. Otherwise, look for
          SUBJECTS_DIR config and return the result.
      raise_error : bool
          If True, raise a KeyError if no value for SUBJECTS_DIR can be found
          (instead of returning None).
  
      Returns
      -------
      value : Path | None
          The SUBJECTS_DIR value.
      """
      if subjects_dir is None:
          subjects_dir = get_config(
              "SUBJECTS_DIR", raise_error=raise_error
          )
      if subjects_dir is not None:
          subjects_dir = _check_fname(
              fname=subjects_dir,
              overwrite="read",
              must_exist=True,
              need_dir=True,
              name="subjects_dir",
          )
      return subjects_dir
  
imports: import atexit
  import json
  import multiprocessing
  import os
  import os.path
  import platform
  import shutil
  import subprocess
  import sys
  import tempfile
  from functools import lru_cache, partial
  from importlib import import_module
  from pathlib import Path
  from urllib.error import URLError
  from urllib.request import urlopen
  from packaging.version import parse
  from ._logging import logger, warn
  from .check import _check_fname, _check_option, _check_qt_version, _validate_type
  from .docs import fill_doc
  from .misc import _pl
label_desc: Use image node_id 8 for calling a global function with example usage: get_subjects_dir(subjects_dir, raise_error) and returns: subjects_dir