class_docstr: Base class for histogram calibrators.
class_docstr_tok: ["Base","class","for","histogram","calibrators","."]
docstr: Starting from start_idx, expand left and right alternately to find the min value of mse loss.
  
  Args:
    start_idx: Index to start quantization.
  
  Returns:
    (min_value, max_value): Min and max calculated.
docstr_tok: ["Starting","from","start_idx",",","expand","left","and","right","alternately","to","find","the","min","value","of","mse","loss",".","Args",":","start_idx",":","Index","to","start","quantization",".","Returns",":","(","min_value",",","max_value",")",":","Min","and","max","calculated","."]
code: def _get_min_max_value_by_expanding_range(
      self, start_idx: int
  ) -> tuple[float, float]:
      """Starting from start_idx, expand left and right alternately to find the min value of mse loss.
  
      Args:
        start_idx: Index to start quantization.
  
      Returns:
        (min_value, max_value): Min and max calculated.
      """
      # Tuple of (mse_error, quant_min, quant_max).
      mse_min = (float("inf"), float("inf"), float("inf"))
      left, right = start_idx, start_idx
  
      # If this value is true, it moves left, otherwise it moves right.
      move_left = True
      while not (left == 0 and right == self._num_bins - 1):
          # Decrease left if right can't be moved or move_left is true.
          if (move_left and left > 0) or (right == self._num_bins - 1):
              left = max(left - 1, 0)
          # Else increase right.
          else:
              right = min(right + 1, self._num_bins - 1)
          # Toogle the move_left.
          move_left = not move_left
          quant_min, quant_max = (
              self._hist_mids[left],
              self._hist_mids[right],
          )
          mse_tuple = self._get_weighted_mean_squared_error(
              quant_min, quant_max
          )
          mse_min = min(mse_tuple, mse_min)
      # Extract (quant_min, quant_max) from (mse_error, quant_min, quant_max).
      min_value, max_value = mse_min[1], mse_min[2]
      return min_value, max_value
  
imports: import abc
  import itertools
  import logging
  import numpy
  from tensorflow.compiler.mlir.quantization.tensorflow import quantization_options_pb2
  from tensorflow.compiler.mlir.quantization.tensorflow.calibrator import calibration_statistics_pb2
label_desc: Use image node_id 4 for calling the _HistogramCalibrationAlgorithmBase obj's underlying member method code with example usage: obj._get_min_max_value_by_expanding_range(start_idx) and returns: min_value,  max_value