code: def _dequantize_weight_decomposed(
      weight: torch.Tensor,
      weight_qscheme: torch.qscheme,
      weight_dtype: torch.dtype,
      weight_scale: torch.Tensor,
      weight_zero_point: torch.Tensor,
      weight_axis: int,
      weight_quant_min: typing.Optional[int],
      weight_quant_max: typing.Optional[int],
  ) -> torch.Tensor:
      # TODO: get the quant_min and quant_max from activation_post_process
      _DTYPE_TO_QVALUE_BOUNDS = {
          torch.uint8: (0, 255),
          torch.int8: (-128, 127),
          torch.int32: (-(2**31), 2**31 - 1),
      }
      # TODO: add an util function for converting qdtype to dtype
      _QDTYPE_TO_UNDERLYING_INT_REPR_DTYPE = {
          torch.quint8: torch.uint8,
          torch.qint8: torch.int8,
          torch.qint32: torch.int32,
      }
      weight_dtype_ = _QDTYPE_TO_UNDERLYING_INT_REPR_DTYPE[weight_dtype]
      if weight_quant_min is None or weight_quant_max is None:
          weight_quant_min, weight_quant_max = _DTYPE_TO_QVALUE_BOUNDS[
              weight_dtype_
          ]
      if weight_qscheme == torch.per_tensor_affine:
          if weight_dtype in [torch.quint8, torch.qint8, torch.qint32]:
              weight = (
                  torch.ops.quantized_decomposed.dequantize_per_tensor(
                      weight,
                      weight_scale,
                      weight_zero_point,
                      weight_quant_min,
                      weight_quant_max,
                      weight_dtype_,
                  )
              )
              return weight
      elif weight_qscheme in [
          torch.per_channel_affine,
          torch.per_channel_affine_float_qparams,
      ]:
          # TODO: torch.quint4x2 is not supported
          if weight_dtype in [torch.quint8, torch.qint8, torch.qint32]:
              weight = (
                  torch.ops.quantized_decomposed.dequantize_per_channel(
                      weight,
                      weight_scale,
                      weight_zero_point,
                      weight_axis,
                      weight_quant_min,
                      weight_quant_max,
                      weight_dtype_,
                  )
              )  # type: ignore[arg-type]
              return weight
      raise Exception(
          f"Unsupported dtype and qscheme: {weight_dtype}, {weight_qscheme}"
      )
  
file_path: pytorch/torch/ao/nn/quantized/reference/modules/utils.py
imports: import torch
  import typing
label_desc: Use image node_id 2 for calling a global function with example usage: _dequantize_weight_decomposed(weight, weight_qscheme, weight_dtype, weight_scale, weight_zero_point, weight_axis, weight_quant_min, weight_quant_max) and returns: weight, weight