class_docstr: Unified histogram calibrator
  
  Histogram will be only collected once. compute_amax() performs entropy, percentile, or mse
      calibration based on arguments
  
  Args:
      num_bits: An integer. Number of bits of quantization.
      axis: A tuple. see QuantDescriptor.
      unsigned: A boolean. using unsigned quantization.
      num_bins: An integer. Number of histograms bins. Default 2048.
      grow_method: A string. DEPRECATED. default None.
      skip_zeros: A boolean. If True, skips zeros when collecting data for histogram. Default False.
      torch_hist: A boolean. If True, collect histogram by torch.histc instead of np.histogram. If input tensor
          is on GPU, histc will also be running on GPU. Default False.
class_docstr_tok: ["Unified","histogram","calibrator","Histogram","will","be","only","collected","once",".","compute_amax","(",")","performs","entropy",",","percentile",",","or","mse","calibration","based","on","arguments","Args",":","num_bits",":","An","integer",".","Number","of","bits","of","quantization",".","axis",":","A","tuple",".","see","QuantDescriptor",".","unsigned",":","A","boolean",".","using","unsigned","quantization",".","num_bins",":","An","integer",".","Number","of","histograms","bins",".","Default","2048.","grow_method",":","A","string",".","DEPRECATED",".","default","None",".","skip_zeros",":","A","boolean",".","If","True",",","skips","zeros","when","collecting","data","for","histogram",".","Default","False",".","torch_hist",":","A","boolean",".","If","True",",","collect","histogram","by","torch.histc","instead","of","np.histogram",".","If","input","tensor","is","on","GPU",",","histc","will","also","be","running","on","GPU",".","Default","False","."]
docstr: Compute the amax from the collected histogram
  
  Args:
      method: A string. One of ['entropy', 'mse', 'percentile']
  
  Keyword Arguments:
      stride: An integer. Default 1
      start_bin: An integer. Default 128
      percentils: A float number between [0, 100]. Default 99.99.
  
  Returns:
      amax: a tensor
docstr_tok: ["Compute","the","amax","from","the","collected","histogram","Args",":","method",":","A","string",".","One","of","[","'entropy","'",",","'mse","'",",","'percentile","'","]","Keyword","Arguments",":","stride",":","An","integer",".","Default","1","start_bin",":","An","integer",".","Default","128","percentils",":","A","float","number","between","[","0",",","100","]",".","Default","99.99",".","Returns",":","amax",":","a","tensor"]
code: def compute_amax(
      self,
      method: str,
      *,
      stride: int = 1,
      start_bin: int = 128,
      percentile: float = 99.99,
  ):
      """Compute the amax from the collected histogram
  
      Args:
          method: A string. One of ['entropy', 'mse', 'percentile']
  
      Keyword Arguments:
          stride: An integer. Default 1
          start_bin: An integer. Default 128
          percentils: A float number between [0, 100]. Default 99.99.
  
      Returns:
          amax: a tensor
      """
      if isinstance(self._calib_hist, torch.Tensor):
          calib_hist = self._calib_hist.int().cpu().numpy()
          calib_bin_edges = self._calib_bin_edges.cpu().numpy()
      else:
          calib_hist = self._calib_hist
          calib_bin_edges = self._calib_bin_edges
  
      if method == "entropy":
          calib_amax = _compute_amax_entropy(
              calib_hist,
              calib_bin_edges,
              self._num_bits,
              self._unsigned,
              stride,
              start_bin,
          )
      elif method == "mse":
          calib_amax = _compute_amax_mse(
              calib_hist,
              calib_bin_edges,
              self._num_bits,
              self._unsigned,
              stride,
              start_bin,
          )
      elif method == "percentile":
          calib_amax = _compute_amax_percentile(
              calib_hist, calib_bin_edges, percentile
          )
      else:
          raise TypeError(
              "Unknown calibration method {}".format(method)
          )
  
      return calib_amax
  
imports: from collections import Counter
  import numpy
  from scipy.stats import entropy
  import logging
  import torch
  from csrc.pytorch.pytorch_quantization.calib.calibrator import _Calibrator
  from csrc.pytorch.pytorch_quantization.tensor_quant import fake_tensor_quant
  from csrc.pytorch.pytorch_quantization import nn
  from csrc.pytorch.pytorch_quantization import utils
label_desc: Use image node_id 4 for calling the HistogramCalibrator obj's underlying member method code with example usage: obj.compute_amax(method) and returns: calib_amax