code: def get_mode(orig_string):
      if orig_string is None:
          string = config.mode
      else:
          string = orig_string
      if not isinstance(string, string_types):
          return string  # it is hopefully already a mode...
  
      global instantiated_default_mode
      # The default mode is cached. However, config.mode can change
      # If instantiated_default_mode has the right class, use it.
      if orig_string is None and instantiated_default_mode:
          if string in predefined_modes:
              default_mode_class = predefined_modes[
                  string
              ].__class__.__name__
          else:
              default_mode_class = string
          if (
              instantiated_default_mode.__class__.__name__
              == default_mode_class
          ):
              return instantiated_default_mode
  
      if string in ["Mode", "DebugMode", "NanGuardMode"]:
          if string == "DebugMode":
              # need to import later to break circular dependency.
              from .debugmode import DebugMode
  
              # DebugMode use its own linker.
              ret = DebugMode(optimizer=config.optimizer)
          elif string == "NanGuardMode":
              # need to import later to break circular dependency.
              from .nanguardmode import NanGuardMode
  
              # NanGuardMode use its own linker.
              ret = NanGuardMode(
                  True, True, True, optimizer=config.optimizer
              )
          else:
              # TODO: Can't we look up the name and invoke it rather than using eval here?
              ret = eval(
                  string
                  + "(linker=config.linker, optimizer=config.optimizer)"
              )
      elif string in predefined_modes:
          ret = predefined_modes[string]
      else:
          raise Exception(
              "No predefined mode exist for string: %s" % string
          )
  
      if orig_string is None:
          # Build and cache the default mode
          if theano.config.optimizer_excluding:
              ret = ret.excluding(
                  *theano.config.optimizer_excluding.split(":")
              )
          if theano.config.optimizer_including:
              ret = ret.including(
                  *theano.config.optimizer_including.split(":")
              )
          if theano.config.optimizer_requiring:
              ret = ret.requiring(
                  *theano.config.optimizer_requiring.split(":")
              )
          instantiated_default_mode = ret
  
      return ret
  
imports: from __future__ import absolute_import, print_function, division
  import logging
  import warnings
  import theano
  from theano import gof
  import theano.gof.vm
  from theano import config
  from six import string_types
  from theano.compile.function_module import Supervisor
label_desc: Use image node_id 3 for calling a global function with example usage: get_mode(orig_string) and returns: ret, string, instantiated_default_mode