code: def create_compressor(model, config, *args, **kwargs):
      """
      Helper function for user scripts to generate a compression object
  
      :param model: Model to compress
      :param config: Compressor configuration
      """
      logging.basicConfig(
          format="%(asctime)-15s - %(name)s - %(levelname)s - %(message)s"
      )
      c_framework = config["compression_framework"]
      c_type = config["compression_type"]
      c_str = config["compressor"]
      logger.info(
          "Creating compressor: framework={} type={} compressor={}".format(
              c_framework, c_type, c_str
          )
      )
  
      if c_framework not in COMPRESSORS:
          raise ValueError(
              (
                  'Compression framework "{}" not recognized. Supported frameworks for installed packages: {}\n'
                  + "Please check messages above, it is possible that an import error lead to this situation."
              ).format(c_framework, ", ".join(COMPRESSORS.keys()))
          )
      if c_type not in COMPRESSORS[c_framework]:
          raise ValueError(
              'Compression type "{}" not recognized for framework "{}". Supported types: {}'.format(
                  c_type,
                  c_framework,
                  ", ".join(COMPRESSORS[c_framework].keys()),
              )
          )
      if c_str not in COMPRESSORS[c_framework][c_type]:
          raise ValueError(
              'Compressor "{}" not recognized for framework "{}" and type "{}". Supported compressors: {}'.format(
                  c_str,
                  c_framework,
                  c_type,
                  ", ".join(COMPRESSORS[c_framework][c_type].keys()),
              )
          )
  
      # Check if all op_names can be found in model
      if c_framework == "torch":
          layer_names = {
              ".".join(key.split(".")[:-1])
              for key in model.state_dict().keys()
          }
      elif c_framework == "tensorflow":
          layer_names = {layer.name for layer in model.layers}
      else:
          raise NotImplementedError
      for config_item in config["config_list"]:
          if "op_names" in config_item:
              for op_name in config_item["op_names"]:
                  if op_name not in layer_names:
                      raise ValueError(
                          'op_name "{}" not found in model. Ops found: {}'.format(
                              op_name, layer_names
                          )
                      )
  
      nni_compressor = COMPRESSORS[c_framework][c_type][c_str](
          model=model,
          config_list=config["config_list"],
          *args,
          **kwargs,
      )
  
      compressor = Compressor(
          model, nni_compressor, c_framework, c_type, c_str
      )
  
      return compressor
  
file_path: auptimizer/src/aup/compression/Compressor.py
imports: import copy
  import logging
  import os
  from ..utils import check_missing_key
label_desc: Use image node_id 1 for calling a global function with example usage: create_compressor(model, config) and returns: compressor