code: def symmetric_linear_quantization_params(
      num_bits, saturation_min, saturation_max, per_channel=False
  ):
      """
      Compute the scaling factor with the given quantization range for symmetric quantization.
  
      Args:
          saturation_min (`torch.Tensor`):
              Lower bound for quantization range.
          saturation_max (`torch.Tensor`):
              Upper bound for quantization range.
          per_channel (`bool`, *optional*, defaults to `False`):
              Whether to or not use channel-wise quantization.
  
      Returns:
          `torch.Tensor`: Scaling factor that linearly quantizes the given range between *saturation_min* and
          *saturation_max*.
      """
      # in this part, we do not need any gradient computation,
      # in order to enforce this, we put torch.no_grad()
      with torch.no_grad():
          n = 2 ** (num_bits - 1) - 1
  
          if per_channel:
              scale, _ = torch.max(
                  torch.stack(
                      [saturation_min.abs(), saturation_max.abs()],
                      dim=1,
                  ),
                  dim=1,
              )
              scale = torch.clamp(scale, min=1e-8) / n
  
          else:
              scale = max(saturation_min.abs(), saturation_max.abs())
              scale = torch.clamp(scale, min=1e-8) / n
  
      return scale
  
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 a global function with example usage: symmetric_linear_quantization_params(num_bits, saturation_min, saturation_max, per_channel) and returns: scale