code: def _quantize_tensor(tensor, qtype):
      if not isinstance(tensor, torch.Tensor):
          raise RuntimeError(
              f"_quantize_tensor expecting torch.Tensor as input but found {type(tensor)}"
          )
      if qtype == DQuantType.FP16:
          return _fp32_to_fp16_with_clamp(tensor)
      elif qtype == DQuantType.BFP16:
          return torch.ops.quantization._FloatToBfloat16Quantized(
              tensor
          )
      else:
          raise RuntimeError(
              f"Quantization type {qtype} is not supported"
          )
  
file_path: pytorch/torch/distributed/algorithms/_quantization/quantization.py
imports: import functools
  import torch
  import torch.distributed
  from enum import Enum
label_desc: Use image node_id 2 for calling a global function with example usage: _quantize_tensor(tensor, qtype) and returns: _fp32_to_fp16_with_clamp, torch