class_docstr: This class is to speedup the model with provided weight mask
docstr: Replace all the modules that have changed (weights/inputs/output) shape.
  The new module is created using the same arguments of the to-be-replaced module,
  and correctly inherits its weights.
  
  NOTE: ```func``` type cannot be replaced as it is not a module, thus, one limitation
  is that ```func``` should be not required to be replaced.
code: def replace_compressed_modules(self):
      """
      Replace all the modules that have changed (weights/inputs/output) shape.
      The new module is created using the same arguments of the to-be-replaced module,
      and correctly inherits its weights.
  
      NOTE: ```func``` type cannot be replaced as it is not a module, thus, one limitation
      is that ```func``` should be not required to be replaced.
      """
      for module_name in self.inferred_masks:
          g_node = self.torch_graph.name_to_node[module_name]
          _logger.debug(
              "replace %s, in %s type, with op_type %s",
              module_name,
              g_node.type,
              g_node.op_type,
          )
          if g_node.type == "module":
              super_module, leaf_module = get_module_by_name(
                  self.bound_model, g_node.name
              )
              m_type = g_node.op_type
              if not m_type in replace_module:
                  raise RuntimeError(
                      "Has not supported replacing the module: `{}`".format(
                          m_type
                      )
                  )
              _logger.info(
                  "replace module (name: %s, op_type: %s)",
                  g_node.name,
                  m_type,
              )
              compressed_module = replace_module[m_type](
                  leaf_module, self.inferred_masks[module_name]
              )
              setattr(
                  super_module,
                  g_node.name.split(".")[-1],
                  compressed_module,
              )
          elif g_node.type == "func":
              _logger.info(
                  "Warning: cannot replace (name: %s, op_type: %s) which is func type",
                  module_name,
                  g_node.op_type,
              )
          else:
              raise RuntimeError(
                  "Unsupported node type: {}".format(g_node.type)
              )
  
file_path: auptimizer/src/aup/compression/torch/speedup/compressor.py
imports: import logging
  import torch
  from ..utils.mask_conflict import fix_mask_conflict
  from ..utils.utils import get_module_by_name
  from .compress_modules import replace_module
  from .infer_shape import ModuleMasks, infer_from_mask, infer_from_inshape, infer_from_outshape, set_conv_prune_dim
label_desc: Use image node_id 4 for calling the ModelSpeedup obj's underlying member method code with example usage: obj.replace_compressed_modules() without return types