code: def resolve_name(name):
      """
      Search for the declaration (function or class) with the given name. This will first search the list of aliases to
      see if it was declared with this aliased name, then search treating `name` as a fully qualified name, then search
      the loaded modules for one having a declaration with the given name. If no declaration is found, raise ValueError.
  
      Raises:
          ValueError: When the module is not found.
          ValueError: When the module does not have the specified member.
          ValueError: When multiple modules with the declaration name are found.
          ValueError: When no module with the specified member is found.
  
      """
      # attempt to resolve an alias
      with alias_lock:
          obj = GlobalAliases.get(name)
  
      if name in GlobalAliases and obj is None:
          raise AssertionError
  
      # attempt to resolve a qualified name
      if obj is None and "." in name:
          modname, declname = name.rsplit(".", 1)
  
          try:
              mod = importlib.import_module(modname)
              obj = getattr(mod, declname, None)
          except ModuleNotFoundError as not_found_err:
              raise ValueError(
                  f"Module {modname!r} not found."
              ) from not_found_err
  
          if obj is None:
              raise ValueError(
                  f"Module {modname!r} does not have member {declname!r}."
              )
  
      # attempt to resolve a simple name
      if obj is None:
          # Get all modules having the declaration/import, need to check here that getattr returns something which doesn't
          # equate to False since in places __getattr__ returns 0 incorrectly:
          # https://github.com/tensorflow/tensorboard/blob/a22566561d2b4fea408755a951ac9eaf3a156f8e/
          # tensorboard/compat/tensorflow_stub/pywrap_tensorflow.py#L35
          mods = [
              m
              for m in list(sys.modules.values())
              if getattr(m, name, None)
          ]
  
          if (
              len(mods) > 0
          ):  # found modules with this declaration or import
              if (
                  len(mods) > 1
              ):  # found multiple modules, need to determine if ambiguous or just multiple imports
                  foundmods = set(
                      filter(
                          None,
                          {
                              inspect.getmodule(getattr(m, name))
                              for m in mods
                          },
                      )
                  )  # resolve imports
  
                  if (
                      len(foundmods) > 1
                  ):  # found multiple declarations with the same name
                      modnames = [m.__name__ for m in foundmods]
                      msg = f"Multiple modules ({modnames!r}) with declaration name {name!r} found, resolution is ambiguous."
                      raise ValueError(msg)
                  mods = list(foundmods)
  
              obj = getattr(mods[0], name)
  
          if obj is None:
              raise ValueError(f"No module with member {name!r} found.")
  
      return obj
  
imports: from __future__ import annotations
  import importlib
  import inspect
  import sys
  import threading
label_desc: Use image node_id 2 for calling a global function with example usage: resolve_name(name) and returns: obj