class_docstr: Max calibrator, tracks the maximum value globally
  
  Args:
      calib_desc: A MaxCalibDescriptor.
      num_bits: An integer. Number of bits of quantization.
      axis: A tuple. see QuantDescriptor.
      unsigned: A boolean. using unsigned quantization.
  
  Readonly Properties:
      amaxs: A list of amax. Numpy array is saved as it is likely to be used for some plot.
class_docstr_tok: ["Max","calibrator",",","tracks","the","maximum","value","globally","Args",":","calib_desc",":","A","MaxCalibDescriptor",".","num_bits",":","An","integer",".","Number","of","bits","of","quantization",".","axis",":","A","tuple",".","see","QuantDescriptor",".","unsigned",":","A","boolean",".","using","unsigned","quantization",".","Readonly","Properties",":","amaxs",":","A","list","of","amax",".","Numpy","array","is","saved","as","it","is","likely","to","be","used","for","some","plot","."]
docstr: Tracks the absolute max of all tensors
  
  Args:
      x: A tensor
  
  Raises:
      RuntimeError: If amax shape changes
docstr_tok: ["Tracks","the","absolute","max","of","all","tensors","Args",":","x",":","A","tensor","Raises",":","RuntimeError",":","If","amax","shape","changes"]
code: def collect(self, x):
      """Tracks the absolute max of all tensors
  
      Args:
          x: A tensor
  
      Raises:
          RuntimeError: If amax shape changes
      """
      if torch.min(x) < 0.0:
          x = x.abs()
  
      # Swap axis to reduce.
      axis = (
          self._axis
          if isinstance(self._axis, (list, tuple))
          else [self._axis]
      )
      reduce_axis = []
      for i in range(x.dim()):
          if not i in axis:
              reduce_axis.append(i)
      local_amax = quant_utils.reduce_amax(x, axis=reduce_axis).detach()
      if self._calib_amax is None:
          self._calib_amax = local_amax
      else:
          if local_amax.shape != self._calib_amax.shape:
              raise RuntimeError("amax shape changed!")
          self._calib_amax.copy_(
              torch.max(self._calib_amax, local_amax).data
          )
  
      if self._track_amax:
          self._amaxs.append(local_amax.cpu().numpy())
  
file_path: lightseq/lightseq/training/pytorch_quantization/calib/max.py
imports: import logging
  import torch
  from lightseq.training.pytorch_quantization.calib.calibrator import _Calibrator
  from lightseq.training.pytorch_quantization import utils
label_desc: Use image node_id 3 for calling the MaxCalibrator obj's underlying member method code with example usage: obj.collect(x) without return types