code: def validate_fused_modules_config(
      fuse_module_names: List[Tuple[str]],
      model: nn.Module,
      config: Dict[str, Any],
  ):
      # check the type and length
      if (
          not isinstance(fuse_module_names, List)
          or not all(isinstance(_, tuple) for _ in fuse_module_names)
          or not all(
              isinstance(_, str)
              for fused_pair in fuse_module_names
              for _ in fused_pair
          )
      ):
          raise ValueError(
              f"Expected the type of fused_modules is List[Tuple[str]], but got {type(fuse_module_names)}"
          )
      name2module = {}
      for module_name, module in model.named_modules(
          remove_duplicate=False
      ):
          name2module[module_name] = module
      # check the validation of operations
      for fused_pair in fuse_module_names:
          assert (
              len(fused_pair) >= 2 and len(fused_pair) <= 3
          ), f"Only 2 or 3 modules are supported for fusion, but got {len(fused_pair)}"
          for i, module_name in enumerate(fused_pair):
              assert (
                  module_name in name2module
              ), f"{module_name} doesn't exist in the model"
              module = name2module[module_name]
              if (
                  i == 0
                  and type(module) not in FUSED_MODULES_TYPES_LIST
              ):
                  raise ValueError(
                      f"{module_name} is not supported for module fusion, \
                                   please register it in the FUSED_MODULES_TYPES_LIST"
                  )
              if (
                  i != 0
                  and type(module) in ACTIVATION_MODULES_TYPE_LIST
              ):
                  assert OUTPUT_PREFIX in config.get(
                      "target_names", []
                  ), "If you need to fuse activation functions, a quantization setting for the output in the config_list should be provided"
  
file_path: nni/nni/compression/utils/fused_utils.py
imports: from typing import List, Dict, Any, Tuple
  import torch
  import torch.nn
  from ..base.setting import OUTPUT_PREFIX
label_desc: Use image node_id 1 for calling a global function with example usage: validate_fused_modules_config(fuse_module_names, model, config) without return types