code: def generate_sequence_example(
      video_id: str,
      start: Optional[Sequence[float]],
      end: Optional[Sequence[float]],
      caption: Optional[Sequence[str]],
      asr_start: Sequence[float],
      asr_end: Sequence[float],
      asr_string: Sequence[str],
      features: Sequence[Sequence[float]],
      duration: int,
      split: Sequence[int] = None,
  ):
      """Generate a sequence example."""
  
      # Initiate the sequence example.
      seq_example = tf.train.SequenceExample()
  
      # Add dense captioning annotations if these exist.
      if caption is not None:
          for s, e, c in zip(start, end, caption):
              seq_example.context.feature[
                  "video/timestamps/start"
              ].int64_list.value.append(s)
              seq_example.context.feature[
                  "video/timestamps/end"
              ].int64_list.value.append(e)
              seq_example.context.feature[
                  "caption/string"
              ].bytes_list.value.append(c.encode())
  
      # Add ASR.
      if asr_start:
          for s, e, c in zip(asr_start, asr_end, asr_string):
              seq_example.context.feature[
                  "ASR/timestamps/start"
              ].int64_list.value.append(s)
              seq_example.context.feature[
                  "ASR/timestamps/end"
              ].int64_list.value.append(e)
              seq_example.context.feature[
                  "ASR/string"
              ].bytes_list.value.append(c.encode())
  
      # Add visual features.
      for f in features:
          add_float_list("image/clip_embeddings", f, seq_example)
  
      if split is not None:
          for s in split:
              seq_example.context.feature[
                  "split"
              ].int64_list.value.append(s)
  
      # Add other metadata.
      set_context_bytes("videoid", video_id.encode(), seq_example)
      set_context_int("video/duration", duration, seq_example)
      return seq_example
  
file_path: scenic/scenic/projects/vid2seq/generate_from_file.py
imports: import contextlib
  import math
  import os
  from typing import Optional, Sequence
  from absl import app
  from absl import flags
  import numpy
  import pandas
  import tensorflow
  from tqdm import tqdm
label_desc: Use image node_id 9 for calling a global function with example usage: generate_sequence_example(video_id, start, end, caption, asr_start, asr_end, asr_string, features, duration, split) and returns: seq_example