code: def redundancy_clean(model, deepspeed_config, mpu=None):
      """
      Remove the redundancy of a model
      Args:
          model (`torch.nn.Module`)
              The model to compress.
          deepspeed_config (`DeepSpeedConfig`)
              The path of ds_config
          mpu
              The mpu module for Row/Column parallelism
      """
      compress_methods = get_compression_config(
          check_deepspeed_config(deepspeed_config)
      )
      if hasattr(model, "module"):
          c_model = model.module
      else:
          c_model = model
  
      layer_added_compress_methods_tmp = get_compress_methods(
          c_model, compress_methods, mpu=mpu
      )
      # sort methods
      order_list = [
          WEIGHT_QUANTIZATION,
          SPARSE_PRUNING,
          ROW_PRUNING,
          HEAD_PRUNING,
          CHANNEL_PRUNING,
          ACTIVATION_QUANTIZATION,
      ]
      layer_added_compress_methods = sorted(
          layer_added_compress_methods_tmp,
          key=lambda x: order_list.index(list(x[2].keys())[0]),
      )
  
      for (
          module_name_lists,
          related_module_name_lists,
          compression_technique,
      ) in layer_added_compress_methods:
          stored_mask = []
          need_mask = True if related_module_name_lists else False
          for i, mnl in enumerate(module_name_lists):
              for module_name in mnl:
                  mask = fix_compression(
                      c_model,
                      module_name,
                      compression_technique,
                      dim_reduction=need_mask,
                  )
                  if need_mask:
                      stored_mask.append(mask)
              if need_mask:
                  for rmnl in related_module_name_lists[i]:
                      for j, module_name in enumerate(rmnl):
                          mask = fix_compression(
                              c_model,
                              module_name,
                              compression_technique,
                              mask=stored_mask[j],
                              dim_reduction=True,
                          )
      return model
  
file_path: H2O/h2o_flexgen/benchmark/third_party/DeepSpeed/deepspeed/compression/compress.py
imports: import re
  from .helper import compression_preparation, fix_compression, recursive_getattr, is_module_compressible
  from .config import get_compression_config
  from ..runtime.config_utils import dict_raise_error_on_duplicate_keys
  from .constants import *
  import os
  import json
label_desc: Use image node_id 5 for calling a global function with example usage: redundancy_clean(model, deepspeed_config, mpu) and returns: model