code: def _fix_random(setup_method_name, teardown_method_name):
      # TODO(niboshi): Prevent this decorator from being applied within
      #    condition.repeat or condition.retry decorators. That would repeat
      #    tests with the same random seeds. It's okay to apply this outside
      #    these decorators.
  
      def decorator(impl):
          if isinstance(
              impl, types.FunctionType
          ) and impl.__name__.startswith("test_"):
              # Applied to test method
              @functools.wraps(impl)
              def test_func(self, *args, **kw):
                  _setup_random()
                  try:
                      impl(self, *args, **kw)
                  finally:
                      _teardown_random()
  
              return test_func
  
          if isinstance(impl, _bundle._ParameterizedTestCaseBundle):
              cases = impl
          else:
              tup = _bundle._TestCaseTuple(impl, None, None)
              cases = _bundle._ParameterizedTestCaseBundle([tup])
  
          for klass, _, _ in cases.cases:
              # Applied to test case class
  
              def make_methods():
                  # make_methods is required to bind the variables prev_setup and
                  # prev_teardown.
                  prev_setup = getattr(klass, setup_method_name)
                  prev_teardown = getattr(klass, teardown_method_name)
  
                  @functools.wraps(prev_setup)
                  def new_setup(self):
                      _setup_random()
                      prev_setup(self)
  
                  @functools.wraps(prev_teardown)
                  def new_teardown(self):
                      try:
                          prev_teardown(self)
                      finally:
                          _teardown_random()
  
                  return new_setup, new_teardown
  
              setup, teardown = make_methods()
  
              setattr(klass, setup_method_name, setup)
              setattr(klass, teardown_method_name, teardown)
  
          return cases
  
      return decorator
  
imports: from __future__ import absolute_import
  import atexit
  import functools
  import os
  import random
  import types
  import numpy
  from chainer.backends import cuda
  from chainer.testing import _bundle
label_desc: Use image node_id 10 for calling a global function with example usage: _fix_random(setup_method_name, teardown_method_name) and returns: decorator, cases, test_func, new_setup,  new_teardown