code: def main_function():
      # Handle the --theano arguments
      if "--theano" in sys.argv:
          i = sys.argv.index("--theano")
          import theano
  
          sys.argv[i] = theano.__path__[0]
  
      # Many Theano tests suppose device=cpu, so we need to raise an
      # error if device==gpu.
      # I don't know how to do this check only if we use theano-nose on
      # Theano tests.  So I make an try..except in case the script get
      # reused elsewhere.
      # We should not import theano before call nose.main()
      # As this cause import problem with nosetests.
      # Should we find a way to don't modify sys.path?
      if not os.path.exists("theano/__init__.py"):
          try:
              from theano import config
  
              if config.device != "cpu":
                  raise ValueError(
                      "Theano tests must be run with device=cpu."
                      " This will also run GPU tests when possible.\n"
                      " If you want GPU-related tests to run on a"
                      " specific GPU device, and not the default one,"
                      " you should use the init_gpu_device theano flag."
                  )
          except ImportError:
              pass
  
      # Handle --batch[=n] arguments
      batch_args = [
          arg for arg in sys.argv if arg.startswith("--batch")
      ]
      for arg in batch_args:
          sys.argv.remove(arg)
      batch_size = None
      if len(batch_args):
          if len(batch_args) > 1:
              _logger.warning(
                  "Multiple --batch arguments detected, using the last one "
                  "and ignoring the first ones."
              )
  
          batch_arg = batch_args[-1]
          elems = batch_arg.split("=", 1)
          if len(elems) == 2:
              batch_size = int(elems[1])
  
      # Handle the --debug-batch argument.
      display_batch_output = False
      if "--debug-batch" in sys.argv:
          if not batch_args:
              raise AssertionError(
                  "You can only use the --debug-batch argument with the "
                  "--batch[=n] option"
              )
          while "--debug-batch" in sys.argv:
              sys.argv.remove("--debug-batch")
          sys.argv += ["--verbose", "--nocapture", "--detailed-errors"]
          display_batch_output = True
  
      # Handle --time_prof arguments
      time_prof_args = [
          arg for arg in sys.argv if arg == "--time-profile"
      ]
      for arg in time_prof_args:
          sys.argv.remove(arg)
  
      # Time-profiling and batch modes
      if time_prof_args or batch_args:
          from theano.tests import run_tests_in_batch
  
          return run_tests_in_batch.main(
              theano_nose=os.path.realpath(__file__),
              batch_size=batch_size,
              time_profile=bool(time_prof_args),
              display_batch_output=display_batch_output,
          )
  
      # Non-batch mode.
      addplugins = []
      # We include KnownFailure plugin by default, unless
      # it is disabled by the "--without-knownfailure" arg.
      if "--without-knownfailure" not in sys.argv:
          try:
              from numpy.testing.noseclasses import KnownFailure
  
              addplugins.append(KnownFailure())
          except ImportError:
              _logger.warning(
                  "KnownFailure plugin from NumPy could not be imported. "
                  "Use --without-knownfailure to disable this warning."
              )
      else:
          sys.argv.remove("--without-knownfailure")
  
      # When 'theano-nose' is called-back under the time-profile option, an
      # instance of the custom Nosetests plugin class 'DisabDocString' (see
      # below) is loaded. The latter ensures that the test name will not be
      # replaced in display by the first line of the documentation string.
      if "--disabdocstring" in sys.argv:
          addplugins.append(DisabDocString())
  
      try:
          if addplugins:
              ret = nose.main(addplugins=addplugins)
          else:
              ret = nose.main()
          return ret
      except TypeError as e:
          if (
              "got an unexpected keyword argument 'addplugins'"
              in e.message
          ):
              # This means nose is too old and does not support plugins
              _logger.warning(
                  "KnownFailure plugin from NumPy can't"
                  " be used as nosetests is too old. "
                  "Use --without-knownfailure to disable this warning."
              )
              nose.main()
          else:
              raise
  
file_path: Theano/bin/theano_nose.py
imports: from __future__ import print_function
  import logging
  import os
  import nose
  import textwrap
  import sys
  import warnings
  from nose.plugins import Plugin
label_desc: Use image node_id 1 for calling a global function with example usage: main_function() and returns: run_tests_in_batch, ret