code: def run_tests(self):
      # Import absl inside run, where dependencies have been loaded already.
      from absl import app  # pylint: disable=g-import-not-at-top
  
      def main(_):
          # pybullet imports multiprocessing in their setup.py, which causes an
          # issue when we import multiprocessing.pool.dummy down the line because
          # the PYTHONPATH has changed.
          for module in [
              "multiprocessing",
              "multiprocessing.pool",
              "multiprocessing.dummy",
              "multiprocessing.pool.dummy",
          ]:
              if module in sys.modules:
                  del sys.modules[module]
          # Reimport multiprocessing to avoid spurious error printouts. See
          # https://bugs.python.org/issue15881.
          import multiprocessing as _  # pylint: disable=g-import-not-at-top
          import tensorflow as tf  # pylint: disable=g-import-not-at-top
  
          # Sets all GPUs to 1GB of memory. The process running the bulk of the unit
          # tests allocates all GPU memory because by default TensorFlow allocates
          # all GPU memory during initialization. This causes tests in
          # run_seperately to fail with out of memory errors because they are run as
          # a subprocess of the process holding the GPU memory.
          gpus = tf.config.experimental.list_physical_devices("GPU")
          for gpu in gpus:
              tf.config.set_logical_device_configuration(
                  gpu,
                  [
                      tf.config.LogicalDeviceConfiguration(
                          memory_limit=1024
                      )
                  ],
              )
  
          run_separately = load_test_list("test_individually.txt")
          broken_tests = load_test_list(FLAGS.broken_tests)
  
          test_loader = TestLoader(
              exclude_list=run_separately + broken_tests
          )
          test_suite = test_loader.discover(
              "tf_agents", pattern="*_test.py"
          )
          stderr = StderrWrapper()
          result = unittest.TextTestResult(
              stderr, descriptions=True, verbosity=2
          )
          test_suite.run(result)
  
          external_test_failures = []
  
          for test in run_separately:
              filename = "tf_agents/%s.py" % test.replace(".", "/")
              try:
                  subprocess.check_call([sys.executable, filename])
              except subprocess.CalledProcessError as e:
                  external_test_failures.append(e)
  
          result.printErrors()
  
          for failure in external_test_failures:
              stderr.writeln(str(failure))
  
          final_output = "Tests run: {} grouped and {} external.  ".format(
              result.testsRun, len(run_separately)
          ) + "Errors: {}  Failures: {}  External failures: {}.".format(
              len(result.errors),
              len(result.failures),
              len(external_test_failures),
          )
  
          header = "=" * len(final_output)
          stderr.writeln(header)
          stderr.writeln(final_output)
          stderr.writeln(header)
  
          if result.wasSuccessful() and not external_test_failures:
              return 0
          else:
              return 1
  
      # Run inside absl.app.run to ensure flags parsing is done.
      from tf_agents.system import (
          system_multiprocessing as multiprocessing,
      )  # pylint: disable=g-import-not-at-top
  
      return multiprocessing.handle_test_main(lambda: app.run(main))
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import codecs
  import datetime
  import fnmatch
  import io
  import os
  import subprocess
  import sys
  import unittest
  from setuptools import find_packages
  from setuptools import setup
  from setuptools.command.test import test
  from setuptools.dist import Distribution
  import version
label_desc: Use image node_id 1 for calling the Test obj's underlying member method code with example usage: obj.run_tests() and returns: multiprocessing, int, int