code: def _load_images_with_retries(
      image_paths: List[str],
      num_retries: int = 10,
      multithreaded: bool = True,
  ) -> torch.Tensor:
      """
      Loads the given image paths using PathManager, decodes them as RGB images and
      returns them as a stacked tensors.
      Args:
          image_paths (List[str]): a list of paths to images.
          num_retries (int): number of times to retry image reading to handle transient error.
          multithreaded (bool): if images are fetched via multiple threads in parallel.
      Returns:
          A tensor of the clip's RGB frames with shape:
          (time, height, width, channel). The frames are of type torch.uint8 and
          in the range [0 - 255]. Raises an exception if unable to load images.
      """
      imgs = [None for i in image_paths]
  
      def fetch_image(image_index: int, image_path: str) -> 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:
                  imgs[image_index] = img_rgb
                  return
              else:
                  logging.warning(
                      f"Reading attempt {i}/{num_retries} failed."
                  )
                  time.sleep(1e-6)
  
      optional_threaded_foreach(
          fetch_image, enumerate(image_paths), multithreaded
      )
  
      if any((img is None for img in imgs)):
          raise Exception(
              "Failed to load images from {}".format(image_paths)
          )
  
      return torch.as_tensor(np.stack(imgs))
  
imports: from __future__ import annotations
  import logging
  import math
  import os
  import re
  import time
  from typing import Callable, Dict, List, Optional
  import numpy
  import torch
  import torch.utils.data
  from iopath.common.file_io import g_pathmgr
  from pytorchvideo.data.utils import optional_threaded_foreach
  from .utils import thwc_to_cthw
  from .video import Video
label_desc: Use image node_id 1 for calling a global function with example usage: _load_images_with_retries(image_paths, num_retries, multithreaded) and returns: torch