code: def _load_image_from_path(
      image_path: str, num_retries: int = 10
  ) -> Image:
      """
      Loads the given image path using PathManager and decodes it as an RGB image.
  
      Args:
          image_path (str): the path to the image.
          num_retries (int): number of times to retry image reading to handle transient error.
  
      Returns:
          A PIL Image of the image RGB data with shape:
          (channel, height, width). The frames are of type np.uint8 and
          in the range [0 - 255]. Raises an exception if unable to load images.
      """
      if not _HAS_CV2:
          raise ImportError(
              "opencv2 is required to use FrameVideo. Please "
              "install with 'pip install opencv-python'"
          )
  
      img_arr = None
  
      for i in range(num_retries):
          with g_pathmgr.open(image_path, "rb") as f:
              img_str = np.frombuffer(f.read(), np.uint8)
              img_bgr = cv2.imdecode(img_str, flags=cv2.IMREAD_COLOR)
              img_rgb = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)
          if img_rgb is not None:
              img_arr = img_rgb
              break
          else:
              logging.warning(
                  f"Reading attempt {i}/{num_retries} failed."
              )
              time.sleep(1e-6)
  
      if img_arr is None:
          raise Exception(
              "Failed to load image from {}".format(image_path)
          )
  
      pil_image = Image.fromarray(img_arr)
      return pil_image
  
imports: import logging
  import math
  import random
  import time
  from dataclasses import dataclass
  from enum import Enum
  from typing import Any, Callable, Dict, List, Optional, Tuple
  import numpy
  import torch
  from iopath.common.file_io import g_pathmgr
  from PIL import Image
  from pytorchvideo.data.dataset_manifest_utils import ImageDataset, ImageFrameInfo, VideoClipInfo, VideoDataset, VideoDatasetType
  from pytorchvideo.data.utils import DataclassFieldCaster, load_dataclass_dict_from_csv
  from pytorchvideo.data.video import Video
label_desc: Use image node_id 3 for calling a global function with example usage: _load_image_from_path(image_path, num_retries) and returns: pil_image