code: def _check_subject_src(
      subject, src, name="subject_from", src_name="src"
  ):
      if isinstance(src, str):
          subject_check = src
      elif (
          src is None
      ):  # assume it's correct although dangerous but unlikely
          subject_check = subject
      else:
          subject_check = src._subject
          if subject_check is None:
              warn(
                  "The source space does not contain the subject name, we "
                  "recommend regenerating the source space (and forward / "
                  "inverse if applicable) for better code reliability"
              )
      if subject is None:
          subject = subject_check
      elif subject_check is not None and subject != subject_check:
          raise ValueError(
              "%s does not match %s subject (%s != %s)"
              % (name, src_name, subject, subject_check)
          )
      if subject is None:
          raise ValueError(
              "%s could not be inferred from %s, it must be "
              "specified" % (name, src_name)
          )
      return subject
  
imports: import copy
  import os.path
  import warnings
  import numpy
  from scipy import sparse
  from .fixes import _get_img_fdata
  from .morph_map import read_morph_map
  from .parallel import parallel_func
  from .source_estimate import _BaseSourceEstimate, _BaseSurfaceSourceEstimate, _BaseVolSourceEstimate, _get_ico_tris
  from .source_space._source_space import SourceSpaces, _ensure_src, _grid_interp
  from .surface import _compute_nearest, mesh_edges, read_surface
  from .utils import BunchConst, ProgressBar, _check_fname, _check_option, _custom_lru_cache, _ensure_int, _import_h5io_funcs, _import_nibabel, _validate_type, check_version, fill_doc, get_subjects_dir, logger, use_log_level, verbose, warn
  from .utils import warn
label_desc: Use image node_id 6 for calling a global function with example usage: _check_subject_src(subject, src, name, src_name) and returns: subject