code: def _generate_images_and_annotations(tf_record_file):
      """Yields the images and annotations from a given file.
  
      Args:
        tf_record_file: .tfrecord files.
  
      Yields:
        Waymo images and annotations.
      """
      # Go through all frames
      dataset = tf.data.TFRecordDataset(
          tf_record_file, compression_type=""
      )
      for data in dataset:
          frame = open_dataset.Frame()
          frame.ParseFromString(data.numpy())
  
          image_and_annotation = {
              "context": {"name": frame.context.name},
              "timestamp_micros": frame.timestamp_micros,
          }
  
          camera_calibration = {
              calibration.name: calibration
              for calibration in frame.context.camera_calibrations
          }
          camera_labels = {
              label.name: label for label in frame.camera_labels
          }
  
          # Go through all 5 camera images in the frame
          for frame_image in frame.images:
              labels = None
              if frame_image.name in camera_labels:
                  image_height = camera_calibration[
                      frame_image.name
                  ].height
                  image_width = camera_calibration[
                      frame_image.name
                  ].width
                  labels = _convert_labels(
                      camera_labels[frame_image.name],
                      image_width,
                      image_height,
                  )
  
              camera_name = open_dataset.CameraName.Name.Name(
                  frame_image.name
              )
              image_and_annotation["camera_" + camera_name] = {
                  "image": frame_image.image,
                  "labels": labels,
              }
  
          yield image_and_annotation
  
file_path: datasets/tensorflow_datasets/object_detection/waymo_open_dataset.py
imports: from __future__ import annotations
  import os
  from absl import logging
  import numpy
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  from tensorflow_datasets.proto import waymo_dataset_pb2
  import tensorflow_datasets.public_api
label_desc: Use image node_id 1 for calling a global function with example usage: _generate_images_and_annotations(tf_record_file) without return types