class_docstr: This class is used to get the compression setting for a module.
  The setting configures the relevant basic information of how to compress the current module.
class_docstr_tok: ["This","class","is","used","to","get","the","compression","setting","for","a","module",".","The","setting","configures","the","relevant","basic","information","of","how","to","compress","the","current","module","."]
docstr: Return the updated setting for the given module type.
  
  Parameters
  ----------
  module
      A module instance or a module class.
  target_names
      The name of the targets to be compressed.
  update_setting
      Used to update the given module type setting from the registry.
docstr_tok: ["Return","the","updated","setting","for","the","given","module","type",".","Parameters","--","--","--","--","--","module","A","module","instance","or","a","module","class",".","target_names","The","name","of","the","targets","to","be","compressed",".","update_setting","Used","to","update","the","given","module","type","setting","from","the","registry","."]
code: def get(
      cls,
      module_cls_or_name: str | torch.nn.Module | Type[torch.nn.Module],
      config: Dict[str, Any],
  ) -> _SETTING:
      """
      Return the updated setting for the given module type.
  
      Parameters
      ----------
      module
          A module instance or a module class.
      target_names
          The name of the targets to be compressed.
      update_setting
          Used to update the given module type setting from the registry.
      """
      module_cls_name = cls._get_module_cls_name(module_cls_or_name)
      # deepcopy because config might be pop key or modified context
      config = deepcopy(config)
  
      target_names = config.pop("target_names", None)
      update_settings = config.pop("target_settings", None)
      target_settings = deepcopy(
          cls.registry.get(module_cls_name, None)
      )
      assert (
          target_settings is not None
      ), f"{module_cls_name} is not registered, please register setting with {cls.__name__}.register()."
  
      cls._update_shortcut_setting(target_settings, config)
  
      if update_settings:
          cls._update_setting(target_settings, update_settings)
  
      target_names = list(
          target_names if target_names else target_settings.keys()
      )
  
      # by default, if INPUT_PREFIX or OUTPUT_PREFIX is set in target_names,
      # assuem it points to the first parameter of the input or output.
      if INPUT_PREFIX in target_names:
          target_names.remove(INPUT_PREFIX)
          target_names.append(f"{INPUT_PREFIX}0")
      if OUTPUT_PREFIX in target_names:
          target_names.remove(OUTPUT_PREFIX)
          target_names.append(f"{OUTPUT_PREFIX}0")
  
      selected_settings = {}
      for target_name in target_names:
          # TODO: should target_settings[xx_PREFIX] merge with target_settings[f'{xx_PREFIX}{idx_or_name}']?
          if target_name.startswith(INPUT_PREFIX):
              selected_settings[target_name] = deepcopy(
                  target_settings.get(
                      target_name, target_settings[INPUT_PREFIX]
                  )
              )
          elif target_name.startswith(OUTPUT_PREFIX):
              selected_settings[target_name] = deepcopy(
                  target_settings.get(
                      target_name, target_settings[OUTPUT_PREFIX]
                  )
              )
          else:
              selected_settings[target_name] = deepcopy(
                  target_settings[target_name]
              )
  
      return selected_settings
  
file_path: nni/nni/compression/base/setting.py
imports: from __future__ import annotations
  from copy import deepcopy
  from typing import Any, Dict, Literal, Type
  import torch
label_desc: Use image node_id 2 for calling the ModuleSetting obj's underlying member method code with example usage: obj.get(cls, module_cls_or_name, config) and returns: selected_settings