code: def _populate_quantization_component_spec(
      quant_method: _QuantizationMethod,
  ) -> None:
      """Populates default values for QuantizationComponentSpec.
  
      Args:
        quant_method: The quantization method to be updated.
      """
      # Make sure creating one spec per component.
      updated_component_spec = dict()
  
      # Populate default configuration.
      if (
          quant_method.preset_method
          == _PresetMethod.METHOD_STATIC_RANGE_INT8
          or quant_method.preset_method
          == _PresetMethod.METHOD_DYNAMIC_RANGE_INT8
      ):
          updated_component_spec[
              _QuantizationComponent.COMPONENT_ACTIVATION
          ] = _QuantizationComponentSpec(
              quantization_component=_QuantizationComponent.COMPONENT_ACTIVATION,
              tensor_type=_TensorType.TENSORTYPE_INT_8,
          )
          updated_component_spec[
              _QuantizationComponent.COMPONENT_WEIGHT
          ] = _QuantizationComponentSpec(
              quantization_component=_QuantizationComponent.COMPONENT_WEIGHT,
              tensor_type=_TensorType.TENSORTYPE_INT_8,
          )
          updated_component_spec[
              _QuantizationComponent.COMPONENT_BIAS
          ] = _QuantizationComponentSpec(
              quantization_component=_QuantizationComponent.COMPONENT_BIAS,
              tensor_type=_TensorType.TENSORTYPE_INT_32,
          )
      elif (
          quant_method.preset_method
          == _PresetMethod.METHOD_STATIC_RANGE_WEIGHT_ONLY_INT8
      ):
          updated_component_spec[
              _QuantizationComponent.COMPONENT_WEIGHT
          ] = _QuantizationComponentSpec(
              quantization_component=_QuantizationComponent.COMPONENT_WEIGHT,
              tensor_type=_TensorType.TENSORTYPE_INT_8,
          )
  
      # Override if quantization_component_spec is specified.
      if quant_method.quantization_component_specs:
          # Check if the component spec is supported configuration in TF-Quant.
          for (
              component_spec
          ) in quant_method.quantization_component_specs:
              if component_spec.quantization_component in [
                  _QuantizationComponent.COMPONENT_WEIGHT,
                  _QuantizationComponent.COMPONENT_ACTIVATION,
              ]:
                  if (
                      component_spec.tensor_type
                      != _TensorType.TENSORTYPE_INT_8
                  ):
                      raise ValueError(
                          "Only int8 precision is supported for input operands."
                      )
              else:
                  if (
                      component_spec.tensor_type
                      != _TensorType.TENSORTYPE_INT_32
                  ):
                      raise ValueError(
                          "Only int32 precision is supported for bias."
                      )
              # Update with the custom spec.
              updated_component_spec[
                  component_spec.quantization_component
              ] = component_spec
  
      # Update the componet spec
      del quant_method.quantization_component_specs[:]
      quant_method.quantization_component_specs.extend(
          updated_component_spec.values()
      )
  
      if (
          quant_method.preset_method
          == _PresetMethod.METHOD_STATIC_RANGE_INT8
          or quant_method.preset_method
          == _PresetMethod.METHOD_DYNAMIC_RANGE_INT8
      ) and (len(quant_method.quantization_component_specs) != 3):
          raise ValueError(
              "Only 3 components are needed for", quant_method
          )
      elif (
          quant_method.preset_method
          == _PresetMethod.METHOD_STATIC_RANGE_WEIGHT_ONLY_INT8
      ) and len(quant_method.quantization_component_specs) != 1:
          raise ValueError(
              "At least one component spec needs to be specified."
          )
  
imports: import tempfile
  from typing import Mapping, Optional
  from absl import logging
  from tensorflow.compiler.mlir.quantization.tensorflow import quantization_options_pb2
  from tensorflow.compiler.mlir.quantization.tensorflow.python import py_function_lib
  from tensorflow.compiler.mlir.quantization.tensorflow.python import pywrap_quantize_model
  from tensorflow.compiler.mlir.quantization.tensorflow.python import representative_dataset
  from tensorflow.compiler.mlir.quantization.tensorflow.python import save_model
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.python.lib.io import file_io
  from tensorflow.python.saved_model import load
  from tensorflow.python.saved_model import loader_impl
  from tensorflow.python.saved_model import signature_constants
  from tensorflow.python.saved_model import tag_constants
  from tensorflow.python.trackable import autotrackable
  from tensorflow.python.util import tf_export
label_desc: Use image node_id 9 for calling a global function with example usage: _populate_quantization_component_spec(quant_method) without return types