code: def test_layer_modules(
      layer_list: List[Tuple[str, Type[nn.Module]]],
      layer_config: Dict[str, Any],
  ) -> None:
      """For each supported layer, tests that it is instantiated with the correct module
      and DP support.
  
      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):
              if gsm_mode in gsm_mode_blocklist:
                  continue
  
              layer = LayerFactory.create(
                  layer_name=layer_name,
                  gsm_mode=gsm_mode,
                  batch_size=64,
                  **layer_config,
              )
  
              if gsm_mode == "baseline":
                  assert isinstance(layer.module, module)
              elif gsm_mode == "hooks":
                  assert isinstance(layer.module, GradSampleModule)
                  assert not layer.module.force_functorch
              elif gsm_mode == "functorch":
                  assert isinstance(layer.module, GradSampleModule)
                  assert layer.module.force_functorch
              elif gsm_mode == "ew":
                  assert isinstance(
                      layer.module, GradSampleModuleExpandedWeights
                  )
  
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 1 for calling a global function with example usage: test_layer_modules(layer_list, layer_config) without return types