code: def _filter_mode(val):
      # Do not add FAST_RUN_NOGC to this list (nor any other ALL CAPS shortcut).
      # The way to get FAST_RUN_NOGC is with the flag 'linker=c|py_nogc'.
      # The old all capital letter way of working is deprecated as it is not
      # scalable.
      str_options = [
          "Mode",
          "DebugMode",
          "FAST_RUN",
          "NanGuardMode",
          "FAST_COMPILE",
          "DEBUG_MODE",
          "JAX",
          "NUMBA",
      ]
      if val in str_options:
          return val
      # This can be executed before PyTensor is completely imported, so
      # pytensor.compile.mode.Mode is not always available.
      # Instead of isinstance(val, pytensor.compile.mode.Mode),
      # we can inspect the __mro__ of the object!
      for type_ in type(val).__mro__:
          if "pytensor.compile.mode.Mode" in str(type_):
              return val
      raise ValueError(
          f"Expected one of {str_options}, or an instance of pytensor.compile.mode.Mode. "
          f"Instead got: {val}."
      )
  
imports: import errno
  import logging
  import os
  import platform
  import re
  import socket
  import sys
  import textwrap
  import numpy
  from setuptools._distutils.spawn import find_executable
  import pytensor
  from pytensor.configparser import BoolParam, ConfigParam, DeviceParam, EnumStr, FloatParam, IntParam, StrParam, _create_default_config
  from pytensor.utils import LOCAL_BITWIDTH, PYTHON_INT_BITWIDTH, call_subprocess_Popen, maybe_add_to_os_environ_pathlist, output_subprocess_Popen
label_desc: Use image node_id 7 for calling a global function with example usage: _filter_mode(val) and returns: val, val