class_docstr: Set of common testing utils. It is meant to be subclassed by your test.
  See other tests as an example of how this is done.
code: def run_test(
      self,
      x: Union[torch.Tensor, PackedSequence, Tuple],
      module: nn.Module,
      batch_first=True,
      atol=10e-6,
      rtol=10e-5,
      ew_compatible=True,
      chunk_method=iter,
  ):
      grad_sample_modes = ["hooks", "functorch"]
  
      if type(module) is nn.EmbeddingBag or (
          type(x) is not PackedSequence and is_batch_empty(x)
      ):
          grad_sample_modes = ["hooks"]
  
      if ew_compatible and batch_first:
          grad_sample_modes += ["ew"]
  
      for loss_reduction in ["sum", "mean"]:
          for grad_sample_mode in grad_sample_modes:
              with self.subTest(
                  grad_sample_mode=grad_sample_mode,
                  loss_reduction=loss_reduction,
              ):
                  self.run_test_with_reduction(
                      x,
                      module,
                      batch_first=batch_first,
                      loss_reduction=loss_reduction,
                      atol=atol,
                      rtol=rtol,
                      grad_sample_mode=grad_sample_mode,
                      chunk_method=chunk_method,
                  )
  
file_path: opacus/opacus/tests/grad_samples/common.py
imports: import unittest
  from typing import Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from opacus.utils.per_sample_gradients_utils import compute_grad_samples_microbatch_and_opacus, compute_opacus_grad_sample, is_batch_empty
  from torch.nn.utils.rnn import PackedSequence
  from torch.testing import assert_close
label_desc: Use image node_id 1 for calling the GradSampleHooks_test obj's underlying member method code with example usage: obj.run_test(x, module, batch_first, atol, rtol, ew_compatible, chunk_method) without return types