code: def convert_to_torch_precision(precision: Union[int, str]):
      """
      Convert a precision integer or string to the corresponding torch precision.
  
      Parameters
      ----------
      precision
      a precision integer or string from the config.
  
      Returns
      -------
      A torch precision object.
      """
      precision_mapping = {
          16: torch.half,
          "16": torch.half,
          "16-mixed": torch.half,
          "16-true": torch.half,
          "bf16": torch.bfloat16,
          "bf16-mixed": torch.bfloat16,
          "bf16-true": torch.bfloat16,
          32: torch.float32,
          "32": torch.float32,
          "32-true": torch.float32,
          64: torch.float64,
          "64": torch.float64,
          "64-true": torch.float64,
      }
  
      if precision in precision_mapping:
          precision = precision_mapping[precision]
      else:
          raise ValueError(f"Unknown precision: {precision}")
  
      return precision
  
imports: import contextlib
  import logging
  import math
  import sys
  import warnings
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  from lightning.pytorch.accelerators import find_usable_cuda_devices
  from torch import nn
  from autogluon.common.utils.resource_utils import ResourceManager
  from ..constants import DDP_STRATEGIES, OBJECT_DETECTION, OCR
label_desc: Use image node_id 4 for calling a global function with example usage: convert_to_torch_precision(precision) and returns: precision