code: def test_training_state(a_model, state):
      # Check that the state of the Module is the same as previously.
      a_model = a_model.train(mode=state)
      mapping = (
          lambda mod: None
          if not isinstance(mod, nn.ReLU)
          else nn.Identity()
      )
      _ = replace_layers_in_module(a_model, mapping)
      assert all(m.training is state for m in a_model.modules())
  
      unmap = (
          lambda mod: None
          if not isinstance(mod, nn.Identity)
          else nn.ReLU()
      )
      _ = replace_layers_in_module(a_model, unmap)
      assert all(m.training is state for m in a_model.modules())
  
file_path: baal/tests/bayesian/common_test.py
imports: import pytest
  from torch import nn
  from baal.bayesian.common import replace_layers_in_module
label_desc: Use image node_id 7 for calling a global function with example usage: test_training_state(a_model, state) without return types