code: def _populate_quantization_options_default_values(
      quantization_options: _QuantizationOptions,
  ) -> None:
      """Populates default values for QuantizationOptions.
  
      Populates unspecified or unset fields of QuantizationOptions with the default
      values.
  
      * If `op_set` is unspecified, it defaults to `OpSet.XLA`.
      * If `freeze_all_variables` is not set, it defaults to `True`.
      * Check if configurations are set correctly:
        - Per-channel quantization is supported for Uniform Quantized opset only.
  
      Args:
        quantization_options: An instance of QuantizationOptions.
      """
      if (
          quantization_options.op_set
          == quant_opts_pb2.OpSet.OP_SET_UNSPECIFIED
      ):
          quantization_options.op_set = quant_opts_pb2.OpSet.XLA
  
      if not quantization_options.tags:
          quantization_options.tags.append(tag_constants.SERVING)
  
      if not quantization_options.signature_keys:
          quantization_options.signature_keys.append(
              signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY
          )
  
      if not quantization_options.HasField("freeze_all_variables"):
          quantization_options.freeze_all_variables = True
  
      if quantization_options.enable_legacy_weight_only:
          raise ValueError(
              "Legacy weight-only is deprecated. Use weight-only quantization method."
          )
  
      # Converter assumes options are specified. So set SRQ explicitly.
      if (
          quantization_options.quantization_method.preset_method
          == _PresetMethod.METHOD_UNSPECIFIED
      ):
          logging.debug(
              '"preset_method" for QuantizationMethod is not specified.'
              "Static range quantization is used by default."
          )
          quantization_options.quantization_method.preset_method = (
              _PresetMethod.METHOD_STATIC_RANGE_INT8
          )
  
      # Check default quantization option values for weight-only quantization.
      # TODO(b/242805842): Find good minimum_elements_for_weights number for server.
      # please also update default value in tflite converter:
      # tensorflow/compiler/mlir/lite/tf_to_tfl_flatbuffer.cc;l=201
      if quantization_options.min_num_elements_for_weights == 0:
          quantization_options.min_num_elements_for_weights = (
              _DYNAMIC_RANGE_DEFAULT_MIN_NUM_ELEMENTS_FOR_WEIGHTS
          )
          logging.warning(
              (
                  "QuantizationOptions.min_num_elements_for_weights is not set (0)."
                  " Setting to the default value: %d."
              ),
              _DYNAMIC_RANGE_DEFAULT_MIN_NUM_ELEMENTS_FOR_WEIGHTS,
          )
  
      # TODO: b/307900054 - Set the per-channel quantization by default.
      if quantization_options.enable_per_channel_quantization and not (
          (
              quantization_options.op_set
              == quant_opts_pb2.OpSet.UNIFORM_QUANTIZED
              or quantization_options.quantization_method.preset_method
              == _PresetMethod.METHOD_STATIC_RANGE_WEIGHT_ONLY_INT8
          )
          or (
              quantization_options.op_set == quant_opts_pb2.OpSet.XLA
              and quantization_options.quantization_method.preset_method
              == _PresetMethod.METHOD_STATIC_RANGE_INT8
          )
      ):
          raise ValueError(
              "Currently, per-channel quantization is supported for Uniform Quantized"
              " opset, weight only quantization, or XLA opset with static range"
              " quantization."
          )
  
      if (
          quantization_options.quantization_method.preset_method
          == _PresetMethod.METHOD_STATIC_RANGE_WEIGHT_ONLY_INT8
          and (
              quantization_options.op_set
              == quant_opts_pb2.OpSet.UNIFORM_QUANTIZED
              or quantization_options.op_set == quant_opts_pb2.OpSet.TF
          )
      ):
          raise ValueError(
              "TF/Uniform quantized opset does not support weight-only."
          )
  
      if (
          quantization_options.op_set == quant_opts_pb2.OpSet.STABLEHLO
      ) and (
          quantization_options.quantization_method.preset_method
          != _PresetMethod.METHOD_STATIC_RANGE_INT8
      ):
          raise ValueError(
              "StableHLO quantized opset currently only supports static range"
              " quantization via TF Quantizer."
          )
  
      if quantization_options.HasField("debugger_options"):
          # Set `force_graph_mode_calibration` to True to avoid skipping op execution,
          # which are not connected to return ops, during calibration execution.
          # Setting `force_graph_mode_calibration` to True enables execution of the
          # model in graph mode (not eager mode).
          logging.debug(
              "Setting `force_graph_mode_calibration = True` to ensure the debugging "
              "model is executed in graph mode during calibration, rather than eager "
              "mode."
          )
          quantization_options.force_graph_mode_calibration = True
  
          if not quantization_options.debugger_options.log_dir_path:
              quantization_options.debugger_options.log_dir_path = (
                  "/tmp/dumps"
              )
  
          if (
              quantization_options.debugger_options.debugger_type
              == quant_opts_pb2.DebuggerOptions.DebuggerType.DEBUGGER_TYPE_UNSPECIFIED
          ):
              raise ValueError(
                  "Debugger is enabled but debugger type was not specified."
              )
  
          if (
              quantization_options.debugger_options.debugger_type
              == quant_opts_pb2.DebuggerOptions.DebuggerType.DEBUGGER_TYPE_WHOLE_MODEL
              and not quantization_options.debugger_options.unquantized_dump_model_path
          ):
              raise ValueError(
                  "Debugger type whole model verify was used but"
                  " unquantized_dump_model_path was not specified."
              )
  
      # Check and populate quantization component spec.
      _populate_quantization_component_spec(
          quantization_options.quantization_method
      )
      # Verify and populate unit-wise quantization specs.
      _populate_unitwise_quantization_specs(quantization_options)
  
      if (
          quantization_options.quantization_method.preset_method
          == _PresetMethod.METHOD_STATIC_RANGE_INT8
      ):
          # Check and populate calibration options.
          _populate_calibration_options(quantization_options)
  
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 12 for calling a global function with example usage: _populate_quantization_options_default_values(quantization_options) without return types