class_docstr: A standard affine quantizer.
class_docstr_tok: ["A","standard","affine","quantizer","."]
code: def forward(ctx, base, itype, axis=None):
      assert isinstance(itype, qbitsdtype)
      bits = itype.bits
      if axis is None:
          rmin = torch.min(base)
          rmax = torch.max(base)
      else:
          dim = axis_to_dim(base, axis)
          rmin = torch.amin(base, dim=dim, keepdim=True)
          rmax = torch.amax(base, dim=dim, keepdim=True)
      qmin = -(2 ** (bits - 1))
      qmax = 2 ** (bits - 1) - 1
      scale = (rmax - rmin) / (qmax - qmin)
      zeropoint = torch.round(-rmin / scale).to(torch.int8)
      data = torch.clamp(
          torch.round((base - rmin) / scale), min=0, max=2**bits - 1
      ).to(torch.int8)
      data.itype = itype
      return QBitsTensor(data, scale, zeropoint)
  
imports: from dataclasses import dataclass
  from typing import Optional
  import torch
  from torch.autograd import Function
  from torch.utils import _pytree
label_desc: Use image node_id 1 for calling the AffineQuantizer obj's underlying member method code with example usage: obj.forward(ctx, base, itype, axis) and returns: QBitsTensor