code: def get_num_modules(
      self, mod: type[torch.nn.Module] | None = None
  ) -> int:
      m = [m for _, m in self.net.named_modules()]
      if mod is not None:
          m = [_m for _m in m if isinstance(_m, mod)]
      return len(m)
  
file_path: MONAI/tests/test_replace_module.py
imports: from __future__ import annotations
  import unittest
  import torch
  from parameterized import parameterized
  from monai.networks.nets import DenseNet121
  from monai.networks.utils import replace_modules, replace_modules_temp
  from tests.utils import TEST_DEVICES
label_desc: Use image node_id 2 for calling the TestReplaceModule obj's underlying member method code with example usage: obj.get_num_modules(mod) and returns: len