class_docstr: DatasetBuider for Youtube-vis dataset.
code: def _generate_examples(
      self,
      annotations: epath.Path,
      all_frames: epath.Path,
      video_range_to_use: Optional[Tuple[int, int]] = None,
  ):
      beam = tfds.core.lazy_imports.apache_beam
      annotations = json.loads(annotations.read_text())
      video_id_to_tracks, videos = _build_annotations_index(annotations)
      height = self._builder_config.height
      width = self._builder_config.width
      only_frames_with_labels = (
          self._builder_config.only_frames_with_labels
      )
      data_example = {}
  
      def _frame_index(frame_filename):
          """Convert a video frame filename into a numerical index."""
          basename = os.path.basename(os.fspath(frame_filename))
          return int(basename.split(".")[0])
  
      def _process_example(video_id):
          """Process a single video into a data example."""
          video = videos[video_id]
          if only_frames_with_labels:
              frames_list = [
                  all_frames / file for file in video["file_names"]
              ]
          else:
              video_dir = os.path.dirname(video["file_names"][0])
              video_directory = all_frames / video_dir
              frames_list = list(video_directory.glob("*"))
          frames_list = sorted(frames_list, key=_frame_index)
          data_example["metadata"] = _create_metadata(
              video, height, width, len(frames_list)
          )
          data_example["tracks"] = []
          track_annotations = video_id_to_tracks[video_id]
          for track in track_annotations:
              data_example["tracks"].append(
                  _create_per_track_annotation(
                      video, frames_list, track, height, width
                  )
              )
          data_example["video"] = self._maybe_resize_video(frames_list)
          return data_example["metadata"]["video_name"], data_example
  
      video_keys = list(videos.keys())
      if video_range_to_use is not None:
          video_keys = video_keys[
              video_range_to_use[0] : video_range_to_use[1]
          ]
  
      return beam.Create(video_keys) | beam.Map(_process_example)
  
imports: from __future__ import annotations
  import collections
  import json
  import os
  from typing import Any, Dict, List, Optional, Tuple, Union
  from etils import epath
  import numpy
  import tensorflow_datasets.public_api
label_desc: Use image node_id 4 for calling the YoutubeVis obj's underlying member method code with example usage: obj._generate_examples(annotations, all_frames, video_range_to_use) and returns: unknown, int, data_example,  data_example