code: def get_qcomm_codecs(
      qcomms_config: Optional[QCommsConfig],
  ) -> QuantizedCommCodecs:
      codecs = QuantizedCommCodecs()
      if qcomms_config is not None:
          codecs.forward = cast(
              QuantizedCommCodec[QuantizationContext],
              FbgemmQuantizedCommCodec(
                  comm_precision=comm_type_to_sparse_type(
                      qcomms_config.forward_precision
                  ),
                  loss_scale=qcomms_config.forward_loss_scale,
                  is_fwd=True,
                  row_dim=qcomms_config.fp8_quantize_dim
                  if qcomms_config.forward_precision == CommType.FP8
                  else None,
              ),
          )
          codecs.backward = cast(
              QuantizedCommCodec[QuantizationContext],
              FbgemmQuantizedCommCodec(
                  comm_precision=comm_type_to_sparse_type(
                      qcomms_config.backward_precision
                  ),
                  loss_scale=qcomms_config.backward_loss_scale,
                  is_fwd=True
                  if qcomms_config.fp8_bwd_uses_143
                  else False,  # if fp8_bwd_uses_143 is True, bwd will use 1-4-3
                  # if fp8_bwd_uses_143 is False/None, bwd will use 1-5-2
                  row_dim=qcomms_config.fp8_quantize_dim_bwd
                  if qcomms_config.backward_precision == CommType.FP8
                  else None,
              ),
          )
      return codecs
  
file_path: torchrec/torchrec/distributed/fbgemm_qcomm_codec.py
imports: import copy
  import logging
  from dataclasses import dataclass
  from enum import Enum, unique
  from typing import cast, Dict, List, Optional
  import torch
  from fbgemm_gpu.quantize_comm import QuantizationContext, QuantizedCommCodec
  from fbgemm_gpu.split_embedding_configs import SparseType
  from torchrec.distributed.types import CommOp, QuantizedCommCodec, QuantizedCommCodecs
label_desc: Use image node_id 2 for calling a global function with example usage: get_qcomm_codecs(qcomms_config) and returns: codecs