class_docstr: Parameters
  ----------
  
  mode: str
      Mode for linear quantization:
  
      * ``"linear_symmetric"`` (default): Input data are quantized in the range
        ``[-R, R]``, where :math:`R = max(abs(w_r))`.
      * ``"linear"``: Input data are quantized in the range
        :math:`[min(w_r), max(w_r)]`.
  
  dtype: np.generic or mil.type type
      Determines the quantized data type (int8/uint8).
  
      * The allowed values are:
          * ``np.int8`` (the default)
          * ``np.uint8``
          * ``coremltools.converters.mil.mil.types.int8``
          * ``coremltools.converters.mil.mil.types.uint8``
  
  weight_threshold: int
      The size threshold, above which weights are pruned.
      That is, a weight tensor is pruned only if its total number of elements are greater than ``weight_threshold``.
  
      For example, if ``weight_threshold = 1024`` and a weight tensor is of shape ``[10, 20, 1, 1]``, hence ``200``
      elements, it will not be pruned.
  
      * If not provided, it will be set to ``2048``, in which weights bigger than ``2048`` elements are compressed.
class_docstr_tok: ["Parameters","--","--","--","--","--","mode",":","str","Mode","for","linear","quantization",":","*","``","``","linear_symmetric","''","``","(","default",")",":","Input","data","are","quantized","in","the","range","``","[","-R",",","R","]","``",",","where",":","math",":","`","R","=","max","(","abs","(","w_r",")",")","`",".","*","``","``","linear","''","``",":","Input","data","are","quantized","in","the","range",":","math",":","`","[","min","(","w_r",")",",","max","(","w_r",")","]","`",".","dtype",":","np.generic","or","mil.type","type","Determines","the","quantized","data","type","(","int8\/uint8",")",".","*","The","allowed","values","are",":","*","``","np.int8","``","(","the","default",")","*","``","np.uint8","``","*","``","coremltools.converters.mil.mil.types.int8","``","*","``","coremltools.converters.mil.mil.types.uint8","``","weight_threshold",":","int","The","size","threshold",",","above","which","weights","are","pruned",".","That","is",",","a","weight","tensor","is","pruned","only","if","its","total","number","of","elements","are","greater","than","``","weight_threshold","``",".","For","example",",","if","``","weight_threshold","=","1024","``","and","a","weight","tensor","is","of","shape","``","[","10",",","20",",","1",",","1","]","``",",","hence","``","200","``","elements",",","it","will","not","be","pruned",".","*","If","not","provided",",","it","will","be","set","to","``","2048","``",",","in","which","weights","bigger","than","``","2048","``","elements","are","compressed","."]
code: def check_dtype(self, attr, dtype):
      msg = f"dtype={dtype} is unsupported for affine_quantize_weights."
      if not is_builtin(dtype):
          try:
              dtype = numpy_type_to_builtin_type(dtype)
          except TypeError:
              raise ValueError(msg)
  
      if dtype not in self._WEIGHT_AFFINE_DTYPES:
          raise ValueError(msg)
  
imports: import sys
  from abc import ABC, abstractmethod
  from collections import OrderedDict
  from typing import IO, Any, Callable, Dict, Optional, Tuple, Union
  import cattrs
  import numpy
  import yaml
  from attrs import define, field, validators
  from coremltools.converters.mil.mil import Operation, types
  from coremltools.converters.mil.mil.types.type_mapping import is_builtin, numpy_type_to_builtin_type
label_desc: Use image node_id 2 for calling the OpLinearQuantizerConfig obj's underlying member method code with example usage: obj.check_dtype(attr, dtype) without return types