code: def per_sample_grads_utils_test(
      self,
      x,
      model,
      grad_sample_mode,
      is_empty=False,
      atol=10e-5,
      rtol=10e-4,
  ):
      if is_empty:
          with self.assertRaises(RuntimeError):
              check_per_sample_gradients_are_correct(
                  x,
                  model,
                  batch_first=True,
                  atol=atol,
                  rtol=rtol,
                  grad_sample_mode=grad_sample_mode,
              )
          return
  
      assert check_per_sample_gradients_are_correct(
          x,
          model,
          batch_first=True,
          atol=atol,
          rtol=rtol,
          grad_sample_mode=grad_sample_mode,
      )
  
file_path: opacus/opacus/tests/per_sample_gradients_utils_test.py
imports: import unittest
  from typing import Callable
  import hypothesis.strategies
  import torch
  from hypothesis import given, settings
  from opacus.utils.per_sample_gradients_utils import check_per_sample_gradients_are_correct, get_grad_sample_modes
  from torch import nn
  from .grad_samples.common import expander, shrinker
label_desc: Use image node_id 1 for calling the PerSampleGradientsUtilsTest obj's underlying member method code with example usage: obj.per_sample_grads_utils_test(x, model, grad_sample_mode, is_empty, atol, rtol) without return types