code: def _get_precision_from_quantizer(quantizer):
      if isinstance(quantizer, str):
          quantizer_obj = qkeras.get_quantizer(quantizer)
          quantizer = {}
          # Some activations are classes with get_config method
          if hasattr(quantizer_obj, "get_config"):
              quantizer["class_name"] = quantizer_obj.__class__.__name__
              quantizer["config"] = quantizer_obj.get_config()
          # Some activations are just functions
          else:
              quantizer["class_name"] = quantizer_obj.__name__
  
      supported_quantizers = [
          "quantized_bits",
          "quantized_relu",
          "quantized_tanh",
          "quantized_sigmoid",
          "quantized_po2",
          "quantized_relu_po2",
          "linear",
      ]
      signed = True
      rnd = "AP_TRN"
      overflow = "AP_WRAP"
  
      if quantizer["class_name"] in supported_quantizers:
          bits = int(quantizer["config"]["bits"])
          # if integer isn't specified, it should be the same as bits
          integer = (
              int(quantizer["config"].get("integer", bits - 1)) + 1
          )
          # for quantizers use the following default rounding and overflow
          rnd = "AP_RND_CONV"
          overflow = "AP_SAT"
          if quantizer["class_name"] in (
              "quantized_relu",
              "quantized_relu_po2",
          ):
              signed = False
              integer -= 1
          elif quantizer["class_name"] == "quantized_tanh":
              overflow = (
                  "AP_SAT_SYM"
                  if quantizer["config"]["symmetric"]
                  else "AP_SAT"
              )
              integer = 1
          elif quantizer["class_name"] == "quantized_sigmoid":
              integer = 0
              signed = False
  
      elif quantizer["class_name"] in [
          "binary",
          "stochastic_binary",
          "binary_tanh",
      ]:
          bits = 2
          integer = 2
  
      elif quantizer["class_name"] in [
          "ternary",
          "stochastic_ternary",
          "ternary_tanh",
      ]:
          bits = 2
          integer = 2
      else:
          raise Exception(
              "ERROR: Unsupported quantizer: {}".format(
                  quantizer["class_name"]
              )
          )
  
      decimal = bits - integer
  
      if decimal > 0:
          return hls4ml.model.types.FixedPrecisionType(
              width=bits,
              integer=integer,
              signed=signed,
              rounding_mode=rnd,
              saturation_mode=overflow,
          )
      else:
          return hls4ml.model.types.IntegerPrecisionType(
              width=integer, signed=signed
          )
  
file_path: hls4ml/hls4ml/utils/config.py
imports: import json
  import qkeras
  import hls4ml
label_desc: Use image node_id 2 for calling a global function with example usage: _get_precision_from_quantizer(quantizer) and returns: hls4ml, hls4ml