class_docstr: Quantized version of `torch.nn.Linear`. Adds quantization-specific arguments on top of `torch.nn.Linear`.
  
  Args:
      weight_bit (`int`, *optional*, defaults to `8`):
          Bitwidth for the quantized weight.
      bias_bit (`int`, *optional*, defaults to `32`):
          Bitwidth for the quantized bias.
      per_channel (`bool`, *optional*, defaults to `False`):
          Whether or not to use channel-wise quantization.
      quant_mode (`bool`, *optional*, defaults to `False`):
          Whether or not the layer is quantized.
class_docstr_tok: ["Quantized","version","of","`","torch.nn.Linear","`",".","Adds","quantization-specific","arguments","on","top","of","`","torch.nn.Linear","`",".","Args",":","weight_bit","(","`","int","`",",","*","optional","*",",","defaults","to","`","8","`",")",":","Bitwidth","for","the","quantized","weight",".","bias_bit","(","`","int","`",",","*","optional","*",",","defaults","to","`","32","`",")",":","Bitwidth","for","the","quantized","bias",".","per_channel","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","or","not","to","use","channel-wise","quantization",".","quant_mode","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","or","not","the","layer","is","quantized","."]
code: def forward(self, x, prev_act_scaling_factor=None):
      if not self.quant_mode:
          return (
              nn.functional.linear(
                  x, weight=self.weight, bias=self.bias
              ),
              None,
          )
  
      # assert that prev_act_scaling_factor is a scalar tensor
      assert (
          prev_act_scaling_factor is not None
          and prev_act_scaling_factor.shape == (1,)
      ), (
          "Input activation to the QuantLinear layer should be globally (non-channel-wise) quantized. "
          "Please add a QuantAct layer with `per_channel = True` before this QuantAct layer"
      )
  
      w = self.weight
      w_transform = w.data.detach()
      if self.per_channel:
          w_min, _ = torch.min(w_transform, dim=1, out=None)
          w_max, _ = torch.max(w_transform, dim=1, out=None)
      else:
          w_min = w_transform.min().expand(1)
          w_max = w_transform.max().expand(1)
  
      self.fc_scaling_factor = symmetric_linear_quantization_params(
          self.weight_bit, w_min, w_max, self.per_channel
      )
      self.weight_integer = self.weight_function(
          self.weight,
          self.weight_bit,
          self.percentile_mode,
          self.fc_scaling_factor,
      )
  
      bias_scaling_factor = (
          self.fc_scaling_factor * prev_act_scaling_factor
      )
  
      if self.bias is not None:
          self.bias_integer = self.weight_function(
              self.bias, self.bias_bit, False, bias_scaling_factor
          )
  
      prev_act_scaling_factor = prev_act_scaling_factor.view(1, -1)
      x_int = x / prev_act_scaling_factor
  
      return (
          nn.functional.linear(
              x_int, weight=self.weight_integer, bias=self.bias_integer
          )
          * bias_scaling_factor,
          bias_scaling_factor,
      )
  
imports: import decimal
  import numpy
  import torch
  from torch import nn
  from torch.autograd import Function
  from ...utils import logging
label_desc: Use image node_id 3 for calling the QuantLinear obj's underlying member method code with example usage: obj.forward(x, prev_act_scaling_factor) and returns: unknown,  bias_scaling_factor, nn,  None