class_docstr: This is the base class to implement custom selectors to skip certain
  layers during quantization. To implement a custom selector, create a class
  that inherits this class and override `do_quantize()` method.
  
  Examples
  --------
  .. highlight:: python
  .. code-block:: python
  
      class MyLayerSelector(QuantizedLayerSelector):
          def __init__(self):
              super().__init__()
  
          def do_quantize(self, layer, **kwargs):
              ret = super().do_quantize(layer)
              if not ret or layer.name == "dense_2":
                  return False
              return True
  
  
      selector = MyLayerSelector()
      quantized_model = quantize_weights(
          mlmodel, 8, quantization_mode="linear", selector=selector
      )
class_docstr_tok: ["This","is","the","base","class","to","implement","custom","selectors","to","skip","certain","layers","during","quantization",".","To","implement","a","custom","selector",",","create","a","class","that","inherits","this","class","and","override","`","do_quantize","(",")","`","method",".","Examples","--","--","--","--","..","highlight",":",":","python","..","code-block",":",":","python","class","MyLayerSelector","(","QuantizedLayerSelector",")",":","def","__init__","(","self",")",":","super","(",")",".__init__","(",")","def","do_quantize","(","self",",","layer",",","*","*","kwargs",")",":","ret","=","super","(",")",".do_quantize","(","layer",")","if","not","ret","or","layer.name","==","``","dense_2","''",":","return","False","return","True","selector","=","MyLayerSelector","(",")","quantized_model","=","quantize_weights","(","mlmodel",",","8",",","quantization_mode=","''","linear","''",",","selector=selector",")"]
code: def __init__(self):
      self.quantizable_layer_types = {
          "convolution",
          "innerProduct",
          "embedding",
          "embeddingND",
          "batchnorm",
          "scale",
          "bias",
          "loadConstant",
          "loadConstantND",
          "simpleRecurrent",
          "gru",
          "uniDirectionalLSTM",
          "biDirectionalLSTM",
          "batchedMatmul",
          "depthwiseConv",
          "loop",
          "branch",
      }
  
imports: from os import listdir
  from sys import stdout
  import numpy
  from coremltools import ComputeUnit, _logger
  from coremltools._deps import _HAS_KMEANS1D, _kmeans1d
  from coremltools.models import _QUANTIZATION_MODE_CUSTOM_LOOKUP_TABLE, _QUANTIZATION_MODE_DEQUANTIZE, _QUANTIZATION_MODE_LINEAR_QUANTIZATION, _QUANTIZATION_MODE_LINEAR_SYMMETRIC, _QUANTIZATION_MODE_LOOKUP_TABLE_KMEANS, _QUANTIZATION_MODE_LOOKUP_TABLE_LINEAR, _SUPPORTED_QUANTIZATION_MODES, MLModel
  from ...None import _MINIMUM_FP16_SPEC_VERSION, _MINIMUM_QUANTIZED_MODEL_SPEC_VERSION, _SPECIFICATION_VERSION_IOS_14
  from ..utils import _get_model, _macos_version, _wp_to_fp16wp
  from .optimization_utils import _optimize_nn
label_desc: Use image node_id 1 to create a new QuantizedLayerSelector object  with example: obj = QuantizedLayerSelector()