class_docstr: A TestCase class designed to dynamically add various mockers that should be used in every test, mimicking the
  behavior of a class-wide mock when defining one normally will not do.
  
  Useful when a mock requires specific information available only initialized after `TestCase.setUpClass`, such as
  setting an environment variable with that information.
  
  The `add_mocks` function should be ran at the end of a `TestCase`'s `setUp` function, after a call to
  `super().setUp()` such as:
  ```python
  def setUp(self):
      super().setUp()
      mocks = mock.patch.dict(os.environ, {"SOME_ENV_VAR", "SOME_VALUE"})
      self.add_mocks(mocks)
  ```
class_docstr_tok: ["A","TestCase","class","designed","to","dynamically","add","various","mockers","that","should","be","used","in","every","test",",","mimicking","the","behavior","of","a","class-wide","mock","when","defining","one","normally","will","not","do",".","Useful","when","a","mock","requires","specific","information","available","only","initialized","after","`","TestCase.setUpClass","`",",","such","as","setting","an","environment","variable","with","that","information",".","The","`","add_mocks","`","function","should","be","ran","at","the","end","of","a","`","TestCase","`","'s","`","setUp","`","function",",","after","a","call","to","`","super","(",")",".setUp","(",")","`","such","as",":","``","`","python","def","setUp","(","self",")",":","super","(",")",".setUp","(",")","mocks","=","mock.patch.dict","(","os.environ",",","{","``","SOME_ENV_VAR","''",",","``","SOME_VALUE","''","}",")","self.add_mocks","(","mocks",")","``","`"]
docstr: Add custom mocks for tests that should be repeated on each test. Should be called during
  `MockingTestCase.setUp`, after `super().setUp()`.
  
  Args:
      mocks (`mock.Mock` or list of `mock.Mock`):
          Mocks that should be added to the `TestCase` after `TestCase.setUpClass` has been run
docstr_tok: ["Add","custom","mocks","for","tests","that","should","be","repeated","on","each","test",".","Should","be","called","during","`","MockingTestCase.setUp","`",",","after","`","super","(",")",".setUp","(",")","`",".","Args",":","mocks","(","`","mock.Mock","`","or","list","of","`","mock.Mock","`",")",":","Mocks","that","should","be","added","to","the","`","TestCase","`","after","`","TestCase.setUpClass","`","has","been","run"]
code: def add_mocks(self, mocks: Union[mock.Mock, List[mock.Mock]]):
      """
      Add custom mocks for tests that should be repeated on each test. Should be called during
      `MockingTestCase.setUp`, after `super().setUp()`.
  
      Args:
          mocks (`mock.Mock` or list of `mock.Mock`):
              Mocks that should be added to the `TestCase` after `TestCase.setUpClass` has been run
      """
      self.mocks = (
          mocks if isinstance(mocks, (tuple, list)) else [mocks]
      )
      for m in self.mocks:
          m.start()
          self.addCleanup(m.stop)
  
imports: import asyncio
  import os
  import shutil
  import subprocess
  import sys
  import tempfile
  import unittest
  from contextlib import contextmanager
  from functools import partial
  from pathlib import Path
  from typing import List, Union
  from unittest import mock
  import torch
  from ..state import AcceleratorState, PartialState
  from ..utils import gather, is_bnb_available, is_clearml_available, is_comet_ml_available, is_cuda_available, is_datasets_available, is_deepspeed_available, is_dvclive_available, is_mps_available, is_npu_available, is_pandas_available, is_tensorboard_available, is_timm_available, is_torch_version, is_tpu_available, is_transformers_available, is_wandb_available, is_xpu_available, str_to_bool
label_desc: Use image node_id 1 for calling the MockingTestCase obj's underlying member method code with example usage: obj.add_mocks(mocks) without return types