class_docstr: Configuration for specifying how different submodules of a model are palettized by
  :py:class:`DKMPalettizer`.
  
  The ``module_type_configs`` parameter can accept a list of :py:class:`ModuleDKMPalettizerConfig`
  as values for a given module type. The list can specify
  different parameters for different ``weight_threshold`` values. This is useful if
  you want to apply different configs to layers of the same type with weights of different sizes.
  
  For example, to use ``4`` -bit palettization for weights with more than ``1000`` elements and
  ``2`` -bit palettization for weights with more than ``300`` but less than ``1000`` elements,
  create a config as follows:
  
  .. code-block:: python
  
      custom_config = {
          nn.Conv2d: [
              {"n_bits": 4, "cluster_dim": 4, "weight_threshold": 1000},
              {"n_bits": 2, "cluster_dim": 2, "weight_threshold": 300},
          ]
      }
      config = DKMPalettizerConfig.from_dict({"module_type_configs": custom_config})
  
  Args:
      global_config (:py:class:`ModuleDKMPalettizerConfig`): Config to be applied globally
          to all supported modules. Missing values are chosen from the default config.
      module_type_configs (:obj:`dict` of :obj:`str` to :py:class:`ModuleDKMPalettizerConfig`):
          Module type level configs applied to a specific module class, such as :py:class:`torch.nn.Linear`.
          The keys can be either strings or module classes. When ``module_type_config`` is set to ``None``
          for a module type, it is not palettized.
      module_name_configs (:obj:`dict` of :obj:`str` to :py:class:`ModuleDKMPalettizerConfig`):
          Module level configs applied to specific modules.
          The name of the module must be a fully qualified name that can be used to fetch it
          from the top level module using the ``module.get_submodule(target)`` method. When
          ``module_name_config`` is set to ``None`` for a module, it is not palettized.
class_docstr_tok: ["Configuration","for","specifying","how","different","submodules","of","a","model","are","palettized","by",":","py",":","class",":","`","DKMPalettizer","`",".","The","``","module_type_configs","``","parameter","can","accept","a","list","of",":","py",":","class",":","`","ModuleDKMPalettizerConfig","`","as","values","for","a","given","module","type",".","The","list","can","specify","different","parameters","for","different","``","weight_threshold","``","values",".","This","is","useful","if","you","want","to","apply","different","configs","to","layers","of","the","same","type","with","weights","of","different","sizes",".","For","example",",","to","use","``","4","``","-bit","palettization","for","weights","with","more","than","``","1000","``","elements","and","``","2","``","-bit","palettization","for","weights","with","more","than","``","300","``","but","less","than","``","1000","``","elements",",","create","a","config","as","follows",":","..","code-block",":",":","python","custom_config","=","{","nn.Conv2d",":","[","{","``","n_bits","''",":","4",",","``","cluster_dim","''",":","4",",","``","weight_threshold","''",":","1000","}",",","{","``","n_bits","''",":","2",",","``","cluster_dim","''",":","2",",","``","weight_threshold","''",":","300","}",",","]","}","config","=","DKMPalettizerConfig.from_dict","(","{","``","module_type_configs","''",":","custom_config","}",")","Args",":","global_config","(",":","py",":","class",":","`","ModuleDKMPalettizerConfig","`",")",":","Config","to","be","applied","globally","to","all","supported","modules",".","Missing","values","are","chosen","from","the","default","config",".","module_type_configs","(",":","obj",":","`","dict","`","of",":","obj",":","`","str","`","to",":","py",":","class",":","`","ModuleDKMPalettizerConfig","`",")",":","Module","type","level","configs","applied","to","a","specific","module","class",",","such","as",":","py",":","class",":","`","torch.nn.Linear","`",".","The","keys","can","be","either","strings","or","module","classes",".","When","``","module_type_config","``","is","set","to","``","None","``","for","a","module","type",",","it","is","not","palettized",".","module_name_configs","(",":","obj",":","`","dict","`","of",":","obj",":","`","str","`","to",":","py",":","class",":","`","ModuleDKMPalettizerConfig","`",")",":","Module","level","configs","applied","to","specific","modules",".","The","name","of","the","module","must","be","a","fully","qualified","name","that","can","be","used","to","fetch","it","from","the","top","level","module","using","the","``","module.get_submodule","(","target",")","``","method",".","When","``","module_name_config","``","is","set","to","``","None","``","for","a","module",",","it","is","not","palettized","."]
code: def __attrs_post_init__(self):
      if (
          self.global_config is None
          and len(self.module_type_configs) == 0
          and len(self.module_name_configs) == 0
      ):
          self.module_type_configs = _default_module_type_configs
      self._sort_configs_by_weight_threshold(self.global_config)
      for ctype, config in self.module_type_configs.items():
          self.set_module_type(
              ctype, self._sort_configs_by_weight_threshold(config)
          )
      for name, config in self.module_name_configs.items():
          self.set_module_type(
              name, self._sort_configs_by_weight_threshold(config)
          )
  
imports: from collections import OrderedDict
  from typing import Any
  from typing import Callable
  from typing import Dict
  from typing import List
  from typing import NewType
  from typing import Optional
  from typing import Union
  import cattrs
  import torch
  import torch.nn
  from attr import define
  from attr import field
  from attrs import validators
  from coremltools.optimize.torch._utils.torch_utils import maybe_convert_str_to_dtype
  from coremltools.optimize.torch.optimization_config import ModuleOptimizationConfig
  from coremltools.optimize.torch.optimization_config import OptimizationConfig
  from coremltools.optimize.torch.optimization_config import _validate_module_type_keys_factory
label_desc: Use image node_id 1 for calling the DKMPalettizerConfig obj's underlying member method code with example usage: obj.__attrs_post_init__() without return types