code: def _dequantized_weight(qweight, name: str = None):
      """
      Given the first output (qweight) of torch.ops.quantized.conv2d/linear_unpack,
      this returns a dequantized version of the tensor to be added to the context.
      """
      if qweight.qscheme() == _torch.per_tensor_affine:
          quant_dtype_np = TORCH_QTYPE_TO_NP_TYPE[qweight.dtype]
          scale = _np.float32(qweight.q_scale())
          zero_point = quant_dtype_np(qweight.q_zero_point())
          quantized_weights = _torch.int_repr(qweight).numpy()
          dequant_weights = _construct_constexpr_affine_op(
              quantized_weights, zero_point, scale, axis=None, name=name
          )
      # per_channel_affine_float_qparams is same as per_channel_affine except that it
      # expects both scale and zero point to be floating point values.
      elif qweight.qscheme() in {
          _torch.per_channel_affine,
          _torch.per_channel_affine_float_qparams,
      }:
          quant_dtype_np = TORCH_QTYPE_TO_NP_TYPE[qweight.dtype]
          # TODO: How do we set the appropriate dtype here (fp16/fp32)?
          scale = qweight.q_per_channel_scales().numpy()
          if qweight.qscheme() == _torch.per_channel_affine:
              zero_point = quant_dtype_np(
                  qweight.q_per_channel_zero_points().numpy()
              )
          else:
              logger.warning(
                  "Found per_channel_affine_float_qparams qscheme, which isn't directly "
                  "supported by coremltools. Casting zero-points to quantized type loses some "
                  "precision."
              )
              dtype_info = _np.iinfo(quant_dtype_np)
              val = _np.clip(
                  _np.around(
                      qweight.q_per_channel_zero_points().numpy()
                  ),
                  dtype_info.min,
                  dtype_info.max,
              )
              zero_point = quant_dtype_np(val)
          quantized_weights = _torch.int_repr(qweight).numpy()
          axis = _np.int32(qweight.q_per_channel_axis())
          dequant_weights = _construct_constexpr_affine_op(
              quantized_weights, zero_point, scale, axis=axis, name=name
          )
      else:
          raise ValueError(
              f'Unsupported quant scheme "{qweight.qscheme()}"'
          )
      return dequant_weights
  
imports: import numpy
  import torch
  from coremltools import _logger
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Var, types
  from .ops import NUM_TO_TORCH_DTYPE, _create_linear_layer, _get_inputs, promote_input_dtypes
  from .torch_op_registry import register_torch_op
label_desc: Use image node_id 6 for calling a global function with example usage: _dequantized_weight(qweight, name) and returns: dequant_weights