class_docstr: Reader for TFRecords using the MediaSequence format.
  
  The TFRecords already contain features, ASR and captions.
  
  Attributes:
    base_dir: str. The base directory from which the SSTables are read.
    subset: str. The subset of the dataset. The subsets are are determined by
      the tables dictionary..
class_docstr_tok: ["Reader","for","TFRecords","using","the","MediaSequence","format",".","The","TFRecords","already","contain","features",",","ASR","and","captions",".","Attributes",":","base_dir",":","str",".","The","base","directory","from","which","the","SSTables","are","read",".","subset",":","str",".","The","subset","of","the","dataset",".","The","subsets","are","are","determined","by","the","tables","dictionary",".."]
docstr: Default build for this dataset.
  
  Args:
    dataset_configs: dataset configuration.
    is_training: whether or not in training mode.
    num_frames: number of frames per subclip.
    stride: temporal stride to sample frames.
    num_test_clips: number of test clip (1 by default). If more than one, this
      will sample multiple linearly spaced clips within each video at test
      time. If 1, then a single clip in the middle of the video is sampled.
    max_num_captions: Maximum number of captions to keep. If there are more
      captions in the proto, only the first `max_num_captions` will be
      returned is `is_training` is set to `False`. If `is_training` is `True`,
      then `max_num_captions` will be randomly sampled. Finally if the proto
      contains less than `max_num_captions`, we pad with empty srings to make
      sure there are `max_num_captions` in total.
    tokenizer: An instance of a tokenizer.
    append_eos: Whether to append EOS token.
    caption_string: Input feature name in sstable for caption.
docstr_tok: ["Default","build","for","this","dataset",".","Args",":","dataset_configs",":","dataset","configuration",".","is_training",":","whether","or","not","in","training","mode",".","num_frames",":","number","of","frames","per","subclip",".","stride",":","temporal","stride","to","sample","frames",".","num_test_clips",":","number","of","test","clip","(","1","by","default",")",".","If","more","than","one",",","this","will","sample","multiple","linearly","spaced","clips","within","each","video","at","test","time",".","If","1",",","then","a","single","clip","in","the","middle","of","the","video","is","sampled",".","max_num_captions",":","Maximum","number","of","captions","to","keep",".","If","there","are","more","captions","in","the","proto",",","only","the","first","`","max_num_captions","`","will","be","returned","is","`","is_training","`","is","set","to","`","False","`",".","If","`","is_training","`","is","`","True","`",",","then","`","max_num_captions","`","will","be","randomly","sampled",".","Finally","if","the","proto","contains","less","than","`","max_num_captions","`",",","we","pad","with","empty","srings","to","make","sure","there","are","`","max_num_captions","`","in","total",".","tokenizer",":","An","instance","of","a","tokenizer",".","append_eos",":","Whether","to","append","EOS","token",".","caption_string",":","Input","feature","name","in","sstable","for","caption","."]
code: def _build(
      self,
      dataset_configs,  # pytype: disable=signature-mismatch
      is_training: bool = True,
      # Video related parameters.
      num_frames: int = 100,
      stride: int = 1,
      num_test_clips: int = 1,
      max_num_captions: int = 1,
      tokenizer: Optional[tokenizers.TextTokenizer] = None,
      append_eos: bool = True,
      caption_string: str = "caption/string",
  ):
      """Default build for this dataset.
  
      Args:
        dataset_configs: dataset configuration.
        is_training: whether or not in training mode.
        num_frames: number of frames per subclip.
        stride: temporal stride to sample frames.
        num_test_clips: number of test clip (1 by default). If more than one, this
          will sample multiple linearly spaced clips within each video at test
          time. If 1, then a single clip in the middle of the video is sampled.
        max_num_captions: Maximum number of captions to keep. If there are more
          captions in the proto, only the first `max_num_captions` will be
          returned is `is_training` is set to `False`. If `is_training` is `True`,
          then `max_num_captions` will be randomly sampled. Finally if the proto
          contains less than `max_num_captions`, we pad with empty srings to make
          sure there are `max_num_captions` in total.
        tokenizer: An instance of a tokenizer.
        append_eos: Whether to append EOS token.
        caption_string: Input feature name in sstable for caption.
      """
  
      modalities = dataset_configs.get("modalities", ("features",))
      num_frames = dataset_configs.get("num_frames", 100)
      num_bins = dataset_configs.get("num_bins", 100)
      stride = dataset_configs.get("stride", 2)
      max_num_output_words = dataset_configs.get(
          "max_num_output_words", 128
      )
      max_num_captions = dataset_configs.get("max_num_captions", 1)
      caption_string = dataset_configs.get(
          "caption_string", "caption/string"
      )
      input_timestamp_name = dataset_configs.get(
          "input_timestamp_name", "caption/timestamp"
      )
      if "input_timestamp_start_name" in dataset_configs:
          input_timestamp_start_name = dataset_configs.get(
              "input_timestamp_start_name"
          )
          input_timestamp_end_name = dataset_configs.get(
              "input_timestamp_end_name"
          )
      else:
          input_timestamp_start_name = input_timestamp_name + "/start"
          input_timestamp_end_name = input_timestamp_name + "/end"
      input_duration_name = dataset_configs.get(
          "input_duration_name", "video/duration"
      )
      output_raw_timestamp_name = dataset_configs.get(
          "output_raw_timestamp_name", "timestamp"
      )
      output_raw_duration_name = dataset_configs.get(
          "output_raw_duration_name", "duration"
      )
      vocabulary_size = dataset_configs.get("vocabulary_size", 32128)
      input_feature_name = dataset_configs.get(
          "input_feature_name", "image/clip_embeddings"
      )
      output_raw_feature_name = dataset_configs.get(
          "output_raw_feature_name", "features"
      )
      features_dim = dataset_configs.get("features_dim", 768)
      max_events = dataset_configs.get("max_events", 50)
      abs_time_token = dataset_configs.get("abs_time_token", False)
      p = dataset_configs.get("random_temporal_crop_proba", 0.5)
      tmp_only = dataset_configs.get("tmp_only", False)
      split = dataset_configs.get("split", False) and not is_training
      time_format = dataset_configs.get("time_format", "se")
      order = dataset_configs.get("order", "ld")
      notime = dataset_configs.get("notime", False)
      preserve = dataset_configs.get("preserve", True)
      asr_input = "text" in modalities
      corrupt = dataset_configs.get("corrupt", 0.0)
      span_len = dataset_configs.get("span_len", 3.0)
      max_num_input_words = dataset_configs.get(
          "max_num_input_words", 512
      )
      asr_notime = dataset_configs.get("asr_notime", False)
      max_segments = dataset_configs.get("max_segments", 0)
      output_raw_string_name = "caption_strings"
      asr_raw_string_name = "ASR/string"
      keep_raw_string = not is_training
  
      # Init the TF models of the tokenizer.
      tokenizer.initialize()  # pytype: disable=attribute-error
  
      # Visual features
      vid2seq_data_utils.add_embeddings(
          parser_builder=self.parser_builder,
          sampler_builder=self.sampler_builder,
          input_feature_lists_name=input_feature_name,
          output_feature_lists_name=output_raw_feature_name,
          num_frames=num_frames,
          features_dim=features_dim,
          sync_random_state=True,
          output_raw_timestamp_name=output_raw_timestamp_name,
          output_raw_duration_name=output_raw_duration_name,
          is_training=is_training,
          output_raw_string_name=output_raw_string_name,
          p=p,
          t=1000000,  # 1FPS
          preserve=preserve,
          asr_input=asr_input,
          max_segments=max_segments,
      )
  
      # Prep caption, ASR etc...
      vid2seq_data_utils.add_text_with_timestamps(
          parser_builder=self.parser_builder,
          preprocessor_builder=self.preprocessor_builder,
          tokenizer=tokenizer,
          input_feature_name=caption_string,
          input_timestamp_start_name=input_timestamp_start_name,
          input_timestamp_end_name=input_timestamp_end_name,
          input_duration_name=input_duration_name,
          output_raw_timestamp_name=output_raw_timestamp_name,
          output_raw_duration_name=output_raw_duration_name,
          max_events=max_events,
          vocabulary_size=vocabulary_size,
          num_bins=num_bins,
          output_raw_string_name=output_raw_string_name,
          # Always prepend the BOS token to init the generation, and +1 tokens
          # are loaded, which are then splitted into input and target tokens.
          prepend_bos=True,
          append_eos=append_eos,
          keep_raw_string=keep_raw_string,
          max_num_tokens=max_num_output_words + 1,
          abs_time_token=abs_time_token,
          time_format=time_format,
          order=order,
          notime=notime,
          asr_input=asr_input,
          max_num_input_words=max_num_input_words,
          asr_raw_string_name=asr_raw_string_name,
          corrupt=corrupt,
          span_len=span_len,
          tmp_only=tmp_only,
          asr_notime=asr_notime,
          t=1000000,
      )  # 1 FPS
  
      if split:
          self.parser_builder.parse_feature(
              feature_name="split",
              feature_type=tf.io.VarLenFeature(dtype=tf.int64),
              output_name="split",
              is_context=True,
          )
          self.decoder_builder.add_fn(
              fn=tf.sparse.to_dense,
              feature_name="split",
              fn_name="split_sparse_to_dense",
          )
  
      if not is_training:
          self.parser_builder.parse_feature(
              feature_name="videoid",
              feature_type=tf.io.VarLenFeature(dtype=tf.string),
              output_name="videoid",
              is_context=True,
          )
          self.decoder_builder.add_fn(
              fn=tf.sparse.to_dense,
              feature_name="videoid",
              fn_name="videoid_sparse_to_dense",
          )
  
imports: import functools
  from typing import Dict, Iterator, List, Optional, Text, Tuple, Union
  from absl import logging
  from dmvr import tokenizers
  from flax import jax_utils
  import jax
  import jax.numpy
  import numpy
  from scenic.dataset_lib import dataset_utils
  from scenic.projects.t5 import tokenizer
  from scenic.projects.vid2seq import data_utils
  from scenic.projects.vivit.data import video_tfrecord_dataset
  import tensorflow
label_desc: Use image node_id 2 for calling the VTTFRecordDatasetFactory obj's underlying member method code with example usage: obj._build(dataset_configs, is_training, num_frames, stride, num_test_clips, max_num_captions, tokenizer, append_eos, caption_string) without return types