class_docstr: Reader for TFRecords using the MediaSequence format.
docstr: Adds DMVR pre-processors to the dataset.
  
  Args:
    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.
    min_resize: frames are resized so that min width/height is min_resize.
    crop_size: final size of the frame after cropping the resized frames.
    zero_centering_image: whether to have images between [-1, 1] or [0, 1].
    max_num_words: Maximum number of tokens to keep from the text for each
      caption. If there are more tokens, sequence is cropped, if less, the
      caption is padded using the tokenizer pad id.
    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.
    caption_string: Input feature name in sstable for caption.
    num_labels: Number of labels (classification).
    include_verb: Including an additional contrastive video-verb phrase loss
      (where the verb is extracted from the caption using PaLM).
docstr_tok: ["Adds","DMVR","pre-processors","to","the","dataset",".","Args",":","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",".","min_resize",":","frames","are","resized","so","that","min","width\/height","is","min_resize",".","crop_size",":","final","size","of","the","frame","after","cropping","the","resized","frames",".","zero_centering_image",":","whether","to","have","images","between","[","-1",",","1","]","or","[","0",",","1","]",".","max_num_words",":","Maximum","number","of","tokens","to","keep","from","the","text","for","each","caption",".","If","there","are","more","tokens",",","sequence","is","cropped",",","if","less",",","the","caption","is","padded","using","the","tokenizer","pad","id",".","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",".","caption_string",":","Input","feature","name","in","sstable","for","caption",".","num_labels",":","Number","of","labels","(","classification",")",".","include_verb",":","Including","an","additional","contrastive","video-verb","phrase","loss","(","where","the","verb","is","extracted","from","the","caption","using","PaLM",")","."]
code: def _build(
      self,
      is_training: bool = True,
      # Video related parameters.
      num_frames: int = 32,
      stride: int = 1,
      num_test_clips: int = 1,
      min_resize: int = 256,
      crop_size: int = 224,
      zero_centering_image: bool = False,
      # Text related parameters.
      max_num_words: int = 16,
      max_num_captions: int = 1,
      caption_string: str = "caption/string",
      num_labels: int = 0,
      include_verb: bool = False,
  ):
      """Adds DMVR pre-processors to the dataset.
  
      Args:
        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.
        min_resize: frames are resized so that min width/height is min_resize.
        crop_size: final size of the frame after cropping the resized frames.
        zero_centering_image: whether to have images between [-1, 1] or [0, 1].
        max_num_words: Maximum number of tokens to keep from the text for each
          caption. If there are more tokens, sequence is cropped, if less, the
          caption is padded using the tokenizer pad id.
        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.
        caption_string: Input feature name in sstable for caption.
        num_labels: Number of labels (classification).
        include_verb: Including an additional contrastive video-verb phrase loss
          (where the verb is extracted from the caption using PaLM).
      """
      if "rgb" in self._modalities:
          load_modalities.add_image(
              parser_builder=self.parser_builder,
              sampler_builder=self.sampler_builder,
              decoder_builder=self.decoder_builder,
              preprocessor_builder=self.preprocessor_builder,
              postprocessor_builder=self.postprocessor_builder,
              is_training=is_training,
              num_frames=num_frames,
              stride=stride,
              num_test_clips=num_test_clips,
              min_resize=min_resize,
              crop_size=crop_size,
              zero_centering_image=zero_centering_image,
              sync_random_state=True,
          )
      tokenizer = tokenizers.ClipTokenizer()  # dummy tokenizer
      tokenizer.initialize()
      # Note, output feature name is 'text_indices'
      if ";" in caption_string:
          # this is when we have both positives & hard negatives
          pos_neg_max_captions = [1, max_num_captions - 1]
          pos_neg_output_raw_string_name = ["string_pos", "string_neg"]
          pos_neg_output_feature_name = [
              "text_indices_pos",
              "text_indices_neg",
          ]
          for idx, caption_to_add in enumerate(
              caption_string.split(";")
          ):
              load_modalities.add_text(
                  parser_builder=self.parser_builder,
                  decoder_builder=self.decoder_builder,
                  preprocessor_builder=self.preprocessor_builder,
                  input_feature_name=caption_to_add,
                  max_num_captions=pos_neg_max_captions[idx],
                  max_num_tokens=max_num_words,
                  keep_raw_string=True,
                  tokenizer=tokenizer,  # We do not use this tokenizer.
                  is_training=is_training,
                  output_raw_string_name=pos_neg_output_raw_string_name[
                      idx
                  ],
                  output_feature_name=pos_neg_output_feature_name[idx],
              )
      else:
          load_modalities.add_text(
              parser_builder=self.parser_builder,
              decoder_builder=self.decoder_builder,
              preprocessor_builder=self.preprocessor_builder,
              input_feature_name=caption_string,
              max_num_captions=max_num_captions,
              max_num_tokens=max_num_words,
              keep_raw_string=True,
              tokenizer=tokenizer,  # We do not use this tokenizer.
              is_training=is_training,
          )
      if include_verb:
          load_modalities.add_text(
              parser_builder=self.parser_builder,
              decoder_builder=self.decoder_builder,
              preprocessor_builder=self.preprocessor_builder,
              input_feature_name="verb",
              max_num_captions=1,
              max_num_tokens=max_num_words,
              keep_raw_string=True,
              tokenizer=tokenizer,  # We do not use this tokenizer.
              is_training=is_training,
              output_raw_string_name="verb",
              output_feature_name="verb_indices",
          )
  
imports: import functools
  from typing import Dict, Iterator, List, Optional, Text, Tuple, Union
  from absl import logging
  from dmvr import modalities
  from flax import jax_utils
  import jax
  import jax.numpy
  import numpy
  from scenic.dataset_lib import dataset_utils
  from scenic.dataset_lib import datasets
  from scenic.dataset_lib import video_ops
  from scenic.projects.baselines.clip import tokenizer
  from scenic.projects.vivit.data import video_tfrecord_dataset
  import tensorflow
  from dmvr import tokenizers
label_desc: Use image node_id 2 for calling the AVTFRecordDatasetFactory obj's underlying member method code with example usage: obj._build(is_training, num_frames, stride, num_test_clips, min_resize, crop_size, zero_centering_image, max_num_words, max_num_captions, caption_string, num_labels, include_verb) without return types