code: def _compute_amax_mse(
      calib_hist,
      calib_bin_edges,
      num_bits,
      unsigned,
      stride=1,
      start_bin=128,
  ):
      """Returns amax that minimizes MSE of the collected histogram"""
  
      # If calibrator hasn't collected any data, return none
      if calib_bin_edges is None and calib_hist is None:
          return None
  
      counts = torch.from_numpy(calib_hist[:]).float()
      edges = torch.from_numpy(calib_bin_edges[:]).float()
      centers = (edges[1:] + edges[:-1]) / 2
  
      mses = []
      arguments = []
  
      for i in range(start_bin, len(centers), stride):
          amax = centers[i]
          quant_centers = fake_tensor_quant(
              centers, amax, num_bits, unsigned
          )
  
          mse = ((quant_centers - centers) ** 2 * counts).mean()
  
          mses.append(mse)
          arguments.append(i)
  
      logger.debug("mses={}".format(mses))
      argmin = np.argmin(mses)
      calib_amax = centers[arguments[argmin]]
  
      return calib_amax
  
imports: from collections import Counter
  import numpy
  from scipy.stats import entropy
  import logging
  import torch
  from lightseq.training.pytorch_quantization.calib.calibrator import _Calibrator
  from lightseq.training.pytorch_quantization.tensor_quant import fake_tensor_quant
  from lightseq.training.pytorch_quantization import nn
  from lightseq.training.pytorch_quantization import utils
label_desc: Use image node_id 2 for calling a global function with example usage: _compute_amax_mse(calib_hist, calib_bin_edges, num_bits, unsigned, stride, start_bin) and returns: calib_amax, None