code: def dtype_to_data_type(dtype: torch.dtype) -> DataType:
      if dtype == torch.float:
          return DataType.FP32
      elif dtype == torch.float16 or dtype == torch.half:
          return DataType.FP16
      elif dtype == torch.bfloat16:
          return DataType.BF16
      elif dtype in {torch.int, torch.int32}:
          return DataType.INT32
      elif dtype in {torch.long, torch.int64}:
          return DataType.INT64
      elif dtype in {torch.quint8, torch.qint8, torch.int8}:
          return DataType.INT8
      elif dtype == torch.uint8:
          return DataType.UINT8
      elif dtype == torch.quint4x2:
          return DataType.INT4
      elif dtype == torch.quint2x4:
          return DataType.INT2
      else:
          raise Exception(f"Invalid data type {dtype}")
  
imports: from dataclasses import dataclass, field
  from enum import Enum, unique
  from functools import partial
  from math import sqrt
  from typing import Callable, Dict, List, NamedTuple, Optional
  import torch
  from fbgemm_gpu.split_embedding_configs import SparseType
  from fbgemm_gpu.split_table_batched_embeddings_ops_training import PoolingMode
  from torchrec.types import DataType
label_desc: Use image node_id 1 for calling a global function with example usage: dtype_to_data_type(dtype) and returns: DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType