code: def fix_random():
      """Decorator that fixes random numbers in a test.
  
      This decorator can be applied to either a test case class or a test method.
      It should not be applied within ``condition.retry`` or
      ``condition.repeat``.
      """
  
      # 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
          elif isinstance(impl, type) and issubclass(
              impl, unittest.TestCase
          ):
              # Applied to test case class
              klass = impl
  
              def wrap_setUp(f):
                  def func(self):
                      _setup_random()
                      f(self)
  
                  return func
  
              def wrap_tearDown(f):
                  def func(self):
                      try:
                          f(self)
                      finally:
                          _teardown_random()
  
                  return func
  
              klass.setUp = wrap_setUp(klass.setUp)
              klass.tearDown = wrap_tearDown(klass.tearDown)
              return klass
          else:
              raise ValueError(
                  "Can't apply fix_random to {}".format(impl)
              )
  
      return decorator
  
file_path: cupy/cupy/testing/_random.py
imports: import atexit
  import functools
  import numpy
  import os
  import random
  import types
  import unittest
  import cupy
label_desc: Use image node_id 7 for calling a global function with example usage: fix_random() and returns: decorator, test_func, klass, func, func