code: def prevent_leaking_rng():
      # Prevent each test from leaking the rng to all other test when they call
      # torch.manual_seed() or random.seed() or np.random.seed().
      # Note: the numpy rngs should never leak anyway, as we never use
      # np.random.seed() and instead rely on np.random.RandomState instances (see
      # issue #4247). We still do it for extra precaution.
  
      torch_rng_state = torch.get_rng_state()
      builtin_rng_state = random.getstate()
      nunmpy_rng_state = np.random.get_state()
      if torch.cuda.is_available():
          cuda_rng_state = torch.cuda.get_rng_state()
  
      yield
  
      torch.set_rng_state(torch_rng_state)
      random.setstate(builtin_rng_state)
      np.random.set_state(nunmpy_rng_state)
      if torch.cuda.is_available():
          torch.cuda.set_rng_state(cuda_rng_state)
  
file_path: vision/test/conftest.py
imports: import random
  import numpy
  import pytest
  import torch
  from common_utils import CUDA_NOT_AVAILABLE_MSG, IN_FBCODE, IN_OSS_CI, IN_RE_WORKER, MPS_NOT_AVAILABLE_MSG, OSS_CI_GPU_NO_CUDA_MSG
label_desc: Use image node_id 4 for calling a global function with example usage: prevent_leaking_rng() without return types