code: def _add_struct_from_batch(
      batched_struct: Struct,
      scene_num: int,
      subplot_title: str,
      scene_dictionary: Dict[str, Dict[str, Struct]],
      trace_idx: int = 1,
      first_idxs: Optional[torch.Tensor] = None,
  ) -> None:  # pragma: no cover
      """
      Adds the struct corresponding to the given scene_num index to
      a provided scene_dictionary to be passed in to plot_scene
  
      Args:
          batched_struct: the batched data structure to add to the dict
          scene_num: the subplot from plot_batch_individually which this struct
              should be added to
          subplot_title: the title of the subplot
          scene_dictionary: the dictionary to add the indexed struct to
          trace_idx: the trace number, starting at 1 for this struct's trace
      """
      struct = None
      if isinstance(batched_struct, CamerasBase):
          # we can't index directly into camera batches
          R, T = batched_struct.R, batched_struct.T
          r_idx = min(scene_num, len(R) - 1)
          t_idx = min(scene_num, len(T) - 1)
          R = R[r_idx].unsqueeze(0)
          T = T[t_idx].unsqueeze(0)
          struct = CamerasBase(device=batched_struct.device, R=R, T=T)
      elif _is_ray_bundle(
          batched_struct
      ) and not _is_heterogeneous_ray_bundle(batched_struct):
          # for RayBundle we treat the camera count as the batch index
          struct_idx = min(scene_num, _get_len(batched_struct) - 1)
  
          struct = RayBundle(
              **{
                  attr: getattr(batched_struct, attr)[struct_idx]
                  for attr in [
                      "origins",
                      "directions",
                      "lengths",
                      "xys",
                  ]
              }
          )
      elif _is_heterogeneous_ray_bundle(batched_struct):
          # for RayBundle we treat the camera count as the batch index
          struct_idx = min(scene_num, _get_len(batched_struct) - 1)
  
          struct = RayBundle(
              **{
                  attr: getattr(batched_struct, attr)[
                      # pyre-ignore[16]
                      first_idxs[struct_idx] : first_idxs[
                          struct_idx + 1
                      ]
                  ]
                  for attr in [
                      "origins",
                      "directions",
                      "lengths",
                      "xys",
                  ]
              }
          )
  
      else:  # batched meshes and pointclouds are indexable
          struct_idx = min(scene_num, _get_len(batched_struct) - 1)
          # pyre-ignore[16]
          struct = batched_struct[struct_idx]
      trace_name = "trace{}-{}".format(scene_num + 1, trace_idx)
      scene_dictionary[subplot_title][trace_name] = struct
  
imports: import warnings
  from typing import Dict, List, NamedTuple, Optional, Tuple, Union
  import plotly.graph_objects
  import torch
  from plotly.subplots import make_subplots
  from pytorch3d.renderer import HeterogeneousRayBundle, ray_bundle_to_ray_points, RayBundle, TexturesAtlas, TexturesVertex
  from pytorch3d.renderer.camera_utils import camera_to_eye_at_up
  from pytorch3d.renderer.cameras import CamerasBase
  from pytorch3d.structures import join_meshes_as_scene, Meshes, Pointclouds
label_desc: Use image node_id 7 for calling a global function with example usage: _add_struct_from_batch(batched_struct, scene_num, subplot_title, scene_dictionary, trace_idx, first_idxs) without return types