code: def import_script(path):
      """Import a module or script by a given path.
  
      Args:
          path: :obj:`str`, can be either a module import of the form
              [package.]*[module] if the outer most package is in the
              `PYTHONPATH`, or a path to an arbitrary python script.
  
      Returns:
          The loaded python script as a module.
      """
      try:
          module = importlib.import_module(path)
      except ModuleNotFoundError:
          if not os.path.isfile(path):
              raise FileNotFoundError(f"Cannot find script {path}.")
          if not os.path.basename(path).endswith(".py"):
              raise ValueError(
                  f"Expected a python script ending with *.py, "
                  f"found {os.path.basename(path)}."
              )
          import_path = os.path.dirname(os.path.abspath(path))
          sys.path.append(import_path)
          module = importlib.import_module(
              f"{os.path.basename(path).rstrip('.py')}",
              package=f"{os.path.basename(import_path)}",
          )
          sys.path.pop()
      return module
  
imports: import enum
  import importlib
  import os
  import pickle
  import re
  import subprocess
  import sys
  import tempfile
  import time
  from dataclasses import dataclass, field
  from functools import partial
  from typing import Any, Callable, Dict, List, Tuple, Union
label_desc: Use image node_id 3 for calling a global function with example usage: import_script(path) and returns: module