class_docstr: Configuration class for specifying how different submodules of a model are
  quantized by :py:class:`LinearQuantizer`.
  
  In order to disable quantizing a layer or an operation, ``module_type_config`` or
  ``module_name_config`` corresponding to that operation can be set to ``None``.
  
  For example:
  
  .. code-block:: python
  
          # The following config will enable weight only quantization for all layers:
          config = LinearQuantizerConfig.from_dict(
              {
                  "global_config": {
                      "activation_dtype": "float32",
                  }
              }
          )
  
          # The following config will disable quantization for all linear layers and
          # set quantization mode to weight only quantization for convolution layers:
          config = LinearQuantizerConfig.from_dict(
              {
                  "module_type_configs": {
                      "Linear": None,
                      "Conv2d": {
                          "activation_dtype": "float32",
                      },
                  }
              }
          )
  
          # The following config will disable quantization for layers named conv1 and conv2:
          config = LinearQuantizerConfig.from_dict(
              {
                  "module_name_configs": {
                      "conv1": None,
                      "conv2": None,
                  }
              }
          )
  
  Args:
      global_config (:py:class:`ModuleLinearQuantizerConfig`): 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:`ModuleLinearQuantizerConfig`):
          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.
      module_name_configs (:obj:`dict` of :obj:`str` to :py:class:`ModuleLinearQuantizerConfig`):
          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.
      non_traceable_module_names (:obj:`list` of :obj:`str`):
          Names of modules which cannot be traced using ``torch.fx``.
  
  .. note::
      The ``quantization_scheme`` parameter must be the same across all configs.
class_docstr_tok: ["Configuration","class","for","specifying","how","different","submodules","of","a","model","are","quantized","by",":","py",":","class",":","`","LinearQuantizer","`",".","In","order","to","disable","quantizing","a","layer","or","an","operation",",","``","module_type_config","``","or","``","module_name_config","``","corresponding","to","that","operation","can","be","set","to","``","None","``",".","For","example",":","..","code-block",":",":","python","#","The","following","config","will","enable","weight","only","quantization","for","all","layers",":","config","=","LinearQuantizerConfig.from_dict","(","{","``","global_config","''",":","{","``","activation_dtype","''",":","``","float32","''",",","}","}",")","#","The","following","config","will","disable","quantization","for","all","linear","layers","and","#","set","quantization","mode","to","weight","only","quantization","for","convolution","layers",":","config","=","LinearQuantizerConfig.from_dict","(","{","``","module_type_configs","''",":","{","``","Linear","''",":","None",",","``","Conv2d","''",":","{","``","activation_dtype","''",":","``","float32","''",",","}",",","}","}",")","#","The","following","config","will","disable","quantization","for","layers","named","conv1","and","conv2",":","config","=","LinearQuantizerConfig.from_dict","(","{","``","module_name_configs","''",":","{","``","conv1","''",":","None",",","``","conv2","''",":","None",",","}","}",")","Args",":","global_config","(",":","py",":","class",":","`","ModuleLinearQuantizerConfig","`",")",":","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",":","`","ModuleLinearQuantizerConfig","`",")",":","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",".","module_name_configs","(",":","obj",":","`","dict","`","of",":","obj",":","`","str","`","to",":","py",":","class",":","`","ModuleLinearQuantizerConfig","`",")",":","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",".","non_traceable_module_names","(",":","obj",":","`","list","`","of",":","obj",":","`","str","`",")",":","Names","of","modules","which","can","not","be","traced","using","``","torch.fx","``",".","..","note",":",":","The","``","quantization_scheme","``","parameter","must","be","the","same","across","all","configs","."]
code: def from_dict(
      cls, config_dict: _Dict[str, _Any]
  ) -> "LinearQuantizerConfig":
      super().from_dict(config_dict)
      converter = _cattrs.Converter(forbid_extra_keys=True)
      converter.register_structure_hook(
          _ModuleTypeConfigType,
          _structure_from_dict_hook_factory(
              ModuleLinearQuantizerConfig
          ),
      )
      return converter.structure_attrs_fromdict(config_dict, cls)
  
imports: import logging
  from collections import OrderedDict
  from enum import Enum
  from enum import unique
  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.ao.quantization
  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._utils.torch_utils import maybe_convert_str_to_mod_type
  from coremltools.optimize.torch.optimization_config import ModuleOptimizationConfig
  from coremltools.optimize.torch.optimization_config import OptimizationConfig
  from coremltools.optimize.torch.optimization_config import _structure_from_dict_hook_factory
label_desc: Use image node_id 2 for calling the LinearQuantizerConfig obj's underlying member method code with example usage: obj.from_dict(cls, config_dict) and returns: converter