code: def function_scope_seed(request):
      """A function scope fixture that manages rng seeds.
      This fixture automatically initializes the python, numpy and mxnet random
      number generators randomly on every test run.
      def test_ok_with_random_data():
          ...
      To fix the seed used for a test case mark the test function with the
      desired seed:
      @pytest.mark.seed(1)
      def test_not_ok_with_random_data():
          '''This testcase actually works.'''
          assert 17 == random.randint(0, 100)
      When a test fails, the fixture outputs the seed used. The user can then set
      the environment variable MXNET_TEST_SEED to the value reported, then rerun
      the test with:
          pytest --verbose -s <test_module_name.py> -k <failing_test>
      To run a test repeatedly, install pytest-repeat and add the --count argument:
          pip install pytest-repeat
          pytest --verbose -s <test_module_name.py> -k <failing_test> --count 1000
      """
  
      seed = request.node.get_closest_marker("seed")
      env_seed_str = os.getenv("MXNET_TEST_SEED")
  
      if seed is not None:
          seed = seed.args[0]
          assert isinstance(seed, int)
      elif env_seed_str is not None:
          seed = int(env_seed_str)
      else:
          seed = int.from_bytes(os.urandom(4), "big")
  
      post_test_state = np.random.get_state()
      np.random.seed(seed)
      random.seed(seed)
  
      if mx is not None:
          mx.random.seed(seed)
  
      seed_message = (
          "np/mx/python random seeds are set to "
          f"{seed}, use MXNET_TEST_SEED={seed} to reproduce."
      )
  
      # Always log seed on DEBUG log level. This makes sure we can find out the
      # value of the seed even if the test case causes a segfault and subsequent
      # teardown code is not run.
      logging.debug(seed_message)
  
      yield  # run the test
  
      np.random.set_state(post_test_state)
  
imports: from pathlib import Path
  from typing import List, NamedTuple
  import gluonts
  import logging
  import numpy
  import os
  import pandas
  import pytest
  import random
  import sys
  import tempfile
  import warnings
  from gluonts.model import Predictor
  from gluonts.dataset.common import ListDataset
label_desc: Use image node_id 2 for calling a global function with example usage: function_scope_seed(request) without return types