class_docstr: Class to quantize the given floating-point values using symmetric quantization with given range and bitwidth.
class_docstr_tok: ["Class","to","quantize","the","given","floating-point","values","using","symmetric","quantization","with","given","range","and","bitwidth","."]
docstr: Args:
      x (`torch.Tensor`):
          Floating point tensor to be quantized.
      k (`int`):
          Quantization bitwidth.
      percentile_mode (`bool`):
          Whether or not to use percentile calibration.
      scale (`torch.Tensor`):
          Pre-calculated scaling factor for *x*. Note that the current implementation of SymmetricQuantFunction
          requires pre-calculated scaling factor.
  
  Returns:
      `torch.Tensor`: Symmetric-quantized value of *input*.
docstr_tok: ["Args",":","x","(","`","torch.Tensor","`",")",":","Floating","point","tensor","to","be","quantized",".","k","(","`","int","`",")",":","Quantization","bitwidth",".","percentile_mode","(","`","bool","`",")",":","Whether","or","not","to","use","percentile","calibration",".","scale","(","`","torch.Tensor","`",")",":","Pre-calculated","scaling","factor","for","*","x","*",".","Note","that","the","current","implementation","of","SymmetricQuantFunction","requires","pre-calculated","scaling","factor",".","Returns",":","`","torch.Tensor","`",":","Symmetric-quantized","value","of","*","input","*","."]
code: def forward(ctx, x, k, percentile_mode, scale):
      """
      Args:
          x (`torch.Tensor`):
              Floating point tensor to be quantized.
          k (`int`):
              Quantization bitwidth.
          percentile_mode (`bool`):
              Whether or not to use percentile calibration.
          scale (`torch.Tensor`):
              Pre-calculated scaling factor for *x*. Note that the current implementation of SymmetricQuantFunction
              requires pre-calculated scaling factor.
  
      Returns:
          `torch.Tensor`: Symmetric-quantized value of *input*.
      """
      zero_point = torch.tensor(0.0).to(scale.device)
  
      n = 2 ** (k - 1) - 1
      new_quant_x = linear_quantize(x, scale, zero_point, inplace=False)
      new_quant_x = torch.clamp(new_quant_x, -n, n - 1)
  
      ctx.scale = scale
      return new_quant_x
  
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 1 for calling the SymmetricQuantFunction obj's underlying member method code with example usage: obj.forward(ctx, x, k, percentile_mode, scale) and returns: new_quant_x