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_with_reduction(
      self,
      x: Union[torch.Tensor, PackedSequence],
      module: nn.Module,
      batch_first=True,
      loss_reduction="mean",
      atol=10e-6,
      rtol=10e-5,
      grad_sample_mode="hooks",
      chunk_method=iter,
  ):
      if not type(x) is PackedSequence and is_batch_empty(x):
          _ = compute_opacus_grad_sample(
              x,
              module,
              batch_first=batch_first,
              loss_reduction=loss_reduction,
              grad_sample_mode=grad_sample_mode,
          )
          # We've checked opacus can handle 0-sized batch. Microbatch doesn't make sense
          return
      (
          microbatch_grad_samples,
          opacus_grad_samples,
      ) = compute_grad_samples_microbatch_and_opacus(
          x,
          module,
          batch_first=batch_first,
          loss_reduction=loss_reduction,
          grad_sample_mode=grad_sample_mode,
          chunk_method=chunk_method,
      )
  
      self.check_shapes(
          microbatch_grad_samples, opacus_grad_samples, loss_reduction
      )
      self.check_values(
          microbatch_grad_samples,
          opacus_grad_samples,
          loss_reduction,
          atol,
          rtol,
      )
  
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 2 for calling the GradSampleHooks_test obj's underlying member method code with example usage: obj.run_test_with_reduction(x, module, batch_first, loss_reduction, atol, rtol, grad_sample_mode, chunk_method) without return types