class_docstr: An abstract class that defines a data source.
class_docstr_tok: ["An","abstract","class","that","defines","a","data","source","."]
docstr: Load an example as a data dictionary.
  
  Args:
    item_id: the ID of the item to fetch.
    scale_factor: a scale factor to apply to the camera.
  
  Returns:
    A dictionary containing one of more of the following items:
      `rgb`: the RGB pixel values of each ray.
      `rays_dir`: the direction of each ray.
      `rays_origin`: the origin of each ray.
      `rays_pixels`: the pixel center of each ray.
      `metadata`: a dictionary of containing various metadata arrays. Each
        item is an array containing metadata IDs for each ray.
code: def get_item(self, item_id, scale_factor=1.0):
      """Load an example as a data dictionary.
  
      Args:
        item_id: the ID of the item to fetch.
        scale_factor: a scale factor to apply to the camera.
  
      Returns:
        A dictionary containing one of more of the following items:
          `rgb`: the RGB pixel values of each ray.
          `rays_dir`: the direction of each ray.
          `rays_origin`: the origin of each ray.
          `rays_pixels`: the pixel center of each ray.
          `metadata`: a dictionary of containing various metadata arrays. Each
            item is an array containing metadata IDs for each ray.
      """
      rgb = self.load_rgb(item_id)
      if scale_factor != 1.0:
          rgb = image_utils.rescale_image(rgb, scale_factor)
  
      camera = self.load_camera(item_id, scale_factor)
      data = {
          "camera_params": camera.get_parameters(),
          "rgb": rgb,
          "metadata": {},
      }
  
      if self.use_appearance_id:
          data["metadata"]["appearance"] = self.appearance_ids.index(
              self.get_appearance_id(item_id)
          )
      if self.use_camera_id:
          data["metadata"]["camera"] = self.camera_ids.index(
              self.get_camera_id(item_id)
          )
      if self.use_warp_id:
          data["metadata"]["warp"] = self.warp_ids.index(
              self.get_warp_id(item_id)
          )
      if self.use_time:
          data["metadata"]["time"] = self.get_time(item_id)
  
      if self.use_depth:
          depth = self.load_depth(item_id)
          if depth is not None:
              if scale_factor != 1.0:
                  depth = image_utils.rescale_image(depth, scale_factor)
              data["depth"] = depth[..., np.newaxis]
  
      logging.info(
          "\tLoaded item %s: shape=%s, scale_factor=%f, metadata=%s",
          item_id,
          rgb.shape,
          scale_factor,
          str(data.get("metadata")),
      )
  
      return data
  
imports: import abc
  import functools
  import itertools
  from typing import Any, Iterable, Optional, Sequence, Union
  from absl import logging
  from flax import jax_utils
  import jax
  import numpy
  import tensorflow
  from nerfies import camera
  from nerfies import gpath
  from nerfies import image_utils
  from nerfies import tf_camera
  from nerfies import utils
  from tensorflow.python.data.util import nest
label_desc: Use image node_id 31 for calling the DataSource obj's underlying member method code with example usage: obj.get_item(item_id, scale_factor) and returns: data