class_docstr: Base class for histogram calibrators.
class_docstr_tok: ["Base","class","for","histogram","calibrators","."]
docstr: Builds histogram using statistics.histogram_statistics.
  
  lower_bound                                    hist_mid
       v                                            v
       |=========|=========|=========|=========|=========|
                  bin width
  
  Args:
    statistics: Collected calibration statistics.
    calib_opts: Calibration options used for calculating min and max.
docstr_tok: ["Builds","histogram","using","statistics.histogram_statistics",".","lower_bound","hist_mid","v","v","|=========|=========|=========|=========|=========|","bin","width","Args",":","statistics",":","Collected","calibration","statistics",".","calib_opts",":","Calibration","options","used","for","calculating","min","and","max","."]
code: def __init__(
      self,
      statistics: calib_stats_pb2.CalibrationStatistics,
      calib_opts: quant_opts_pb2.CalibrationOptions,
  ):
      """Builds histogram using statistics.histogram_statistics.
  
      lower_bound                                    hist_mid
           v                                            v
           |=========|=========|=========|=========|=========|
                      bin width
  
      Args:
        statistics: Collected calibration statistics.
        calib_opts: Calibration options used for calculating min and max.
      """
      super().__init__(statistics, calib_opts)
      hist_stats = statistics.histogram_statistics
      self._bin_width = hist_stats.bin_width
      self._lower_bound = hist_stats.lower_bound
      self._hist_freq = np.array(hist_stats.hist_freq)
      self._num_bins = len(self._hist_freq)
      self._num_bits = 8
      # i-th bin has a range [bins[i], bins[i + 1]).
      # bins[i] = lower_bound + i * bin_width
      # bins[i + 1] = lower_bound + (i + 1) * bin_width
      # So hist_mids[i] = (lower_bound + bin_width / 2) + bin_width * i
      first_mid = self._lower_bound + self._bin_width / 2
      last_mid = first_mid + (self._num_bins - 1) * self._bin_width
      self._hist_mids = np.linspace(first_mid, last_mid, self._num_bins)
  
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 1 to create a new _HistogramCalibrationAlgorithmBase object from inherited base classes: _CalibrationAlgorithmBase with example: obj = _HistogramCalibrationAlgorithmBase(statistics, calib_opts)