code: def test_forward_backward(
      layer_list: List[Tuple[str, nn.Module]],
      layer_config: Dict[str, Any],
  ) -> None:
      """Tests that Layer.forward_backward() runs for each layer in layer_list and that
      the Layer is not modified.
  
      Args:
          layer_list: list of tuples of form (layer_name, module)
          layer_config: config for instantiating the layers in layer_list
      """
      for layer_name, module, gsm_mode_blocklist in layer_list:
          for gsm_mode in GSM_MODES - set(gsm_mode_blocklist):
              layer = LayerFactory.create(
                  layer_name=layer_name,
                  batch_size=64,
                  gsm_mode=gsm_mode,
                  **layer_config,
              )
              if layer is None:
                  continue
              layer_copy = copy.deepcopy(layer)
              layer.forward_backward()
              for p1, p2 in zip(
                  layer.module.parameters(),
                  layer_copy.module.parameters(),
              ):
                  assert torch.equal(p1.data, p2.data)
  
file_path: opacus/benchmarks/tests/test_layers.py
imports: import copy
  import logging
  import random
  from typing import Any, Dict, List, Tuple, Type
  import pytest
  import torch
  import torch.nn
  from helpers import skipifnocuda
  from opacus.grad_sample import GradSampleModule
  from opacus.grad_sample.gsm_exp_weights import GradSampleModuleExpandedWeights
  from opacus.layers import DPGRU, DPLSTM, DPRNN, DPMultiheadAttention
  from benchmarks.layers import LayerFactory
  from benchmarks.utils import reset_peak_memory_stats
label_desc: Use image node_id 4 for calling a global function with example usage: test_forward_backward(layer_list, layer_config) without return types