class_docstr: Reader for TFRecords using the MediaSequence format.
  
  Attributes:
    num_classes: int. The number of classes in the dataset.
    base_dir: str. The base directory from which the TFRecords are read.
    subset: str. The subset of the dataset. In Scenic, the subsets are
      "train", "validation" and "test".
class_docstr_tok: ["Reader","for","TFRecords","using","the","MediaSequence","format",".","Attributes",":","num_classes",":","int",".","The","number","of","classes","in","the","dataset",".","base_dir",":","str",".","The","base","directory","from","which","the","TFRecords","are","read",".","subset",":","str",".","The","subset","of","the","dataset",".","In","Scenic",",","the","subsets","are","``","train","''",",","``","validation","''","and","``","test","''","."]
docstr: Initializes the instance of TFRecordDatasetFactory.
  
  Initializes a data-loader using DeepMind Video Reader (DMVR) pre-processing
  (https://github.com/deepmind/dmvr).
  TFRecords are assumed to consist of tf.SequenceExample protocol buffers in
  the MediaSequence
  (https://github.com/google/mediapipe/tree/master/mediapipe/util/sequence)
  format.
  
  Args:
    base_dir: The base directory of the TFRecords.
    tables: A dictionary mapping the subset name (train, val or test) to the
      relative path of the TFRecord containing them. Follows DMVR convention.
      The values of the dictionary can either be a string or a list. If it is
      a string, it specifies all the shards in the TFRecord.
      Example - "/path/to/tfrecord@10".
      If passing a list, each entry is a shard of the TFRecord.
      Example - "[/path/to/tfrecord_shard_1_of_10, ...,
                  /path/to/tfrecord_shard_10_of_10]."
      The latter scenario is useful for debugging.
    examples_per_subset:  A dictionary mapping the subset name (train, val or
      test) to the number of examples in the dataset for that subset.
    num_classes: The number of classes in the dataset.
    subset: The subset of the dataset to load. Must be a key of "tables"
    fraction_data: The fraction of the data to load. If less than 1.0, this
      fraction of the total TFRecord shards are read.
    num_groups: If specified will reshard the data according to `num_groups`.
      A `group_index` should be specified if using `num_groups`.
    group_index: Index of the shard to return after resharding. `num_groups`
      should be specified if using `group_index`. This is useful in
      distributed setting where one wants to ensure that different data is
      read by different workers.
  
  Raises:
    ValueError: If subset is not a key of tables or examples_per_subset
docstr_tok: ["Initializes","the","instance","of","TFRecordDatasetFactory",".","Initializes","a","data-loader","using","DeepMind","Video","Reader","(","DMVR",")","pre-processing","(","https",":","\/\/github.com\/deepmind\/dmvr",")",".","TFRecords","are","assumed","to","consist","of","tf.SequenceExample","protocol","buffers","in","the","MediaSequence","(","https",":","\/\/github.com\/google\/mediapipe\/tree\/master\/mediapipe\/util\/sequence",")","format",".","Args",":","base_dir",":","The","base","directory","of","the","TFRecords",".","tables",":","A","dictionary","mapping","the","subset","name","(","train",",","val","or","test",")","to","the","relative","path","of","the","TFRecord","containing","them",".","Follows","DMVR","convention",".","The","values","of","the","dictionary","can","either","be","a","string","or","a","list",".","If","it","is","a","string",",","it","specifies","all","the","shards","in","the","TFRecord",".","Example","-","``","\/path\/to\/tfrecord","@","10","''",".","If","passing","a","list",",","each","entry","is","a","shard","of","the","TFRecord",".","Example","-","``","[","\/path\/to\/tfrecord_shard_1_of_10",",","...",",","\/path\/to\/tfrecord_shard_10_of_10","]",".","''","The","latter","scenario","is","useful","for","debugging",".","examples_per_subset",":","A","dictionary","mapping","the","subset","name","(","train",",","val","or","test",")","to","the","number","of","examples","in","the","dataset","for","that","subset",".","num_classes",":","The","number","of","classes","in","the","dataset",".","subset",":","The","subset","of","the","dataset","to","load",".","Must","be","a","key","of","``","tables","''","fraction_data",":","The","fraction","of","the","data","to","load",".","If","less","than","1.0",",","this","fraction","of","the","total","TFRecord","shards","are","read",".","num_groups",":","If","specified","will","reshard","the","data","according","to","`","num_groups","`",".","A","`","group_index","`","should","be","specified","if","using","`","num_groups","`",".","group_index",":","Index","of","the","shard","to","return","after","resharding",".","`","num_groups","`","should","be","specified","if","using","`","group_index","`",".","This","is","useful","in","distributed","setting","where","one","wants","to","ensure","that","different","data","is","read","by","different","workers",".","Raises",":","ValueError",":","If","subset","is","not","a","key","of","tables","or","examples_per_subset"]
code: def __init__(
      self,
      base_dir: str,
      tables: Dict[str, Union[str, List[str]]],
      examples_per_subset: Dict[str, int],
      num_classes: int,
      subset: str = "train",
      fraction_data: float = 1.0,
      num_groups: Optional[int] = None,
      group_index: Optional[int] = None,
  ):
      """Initializes the instance of TFRecordDatasetFactory.
  
      Initializes a data-loader using DeepMind Video Reader (DMVR) pre-processing
      (https://github.com/deepmind/dmvr).
      TFRecords are assumed to consist of tf.SequenceExample protocol buffers in
      the MediaSequence
      (https://github.com/google/mediapipe/tree/master/mediapipe/util/sequence)
      format.
  
      Args:
        base_dir: The base directory of the TFRecords.
        tables: A dictionary mapping the subset name (train, val or test) to the
          relative path of the TFRecord containing them. Follows DMVR convention.
          The values of the dictionary can either be a string or a list. If it is
          a string, it specifies all the shards in the TFRecord.
          Example - "/path/to/tfrecord@10".
          If passing a list, each entry is a shard of the TFRecord.
          Example - "[/path/to/tfrecord_shard_1_of_10, ...,
                      /path/to/tfrecord_shard_10_of_10]."
          The latter scenario is useful for debugging.
        examples_per_subset:  A dictionary mapping the subset name (train, val or
          test) to the number of examples in the dataset for that subset.
        num_classes: The number of classes in the dataset.
        subset: The subset of the dataset to load. Must be a key of "tables"
        fraction_data: The fraction of the data to load. If less than 1.0, this
          fraction of the total TFRecord shards are read.
        num_groups: If specified will reshard the data according to `num_groups`.
          A `group_index` should be specified if using `num_groups`.
        group_index: Index of the shard to return after resharding. `num_groups`
          should be specified if using `group_index`. This is useful in
          distributed setting where one wants to ensure that different data is
          read by different workers.
  
      Raises:
        ValueError: If subset is not a key of tables or examples_per_subset
      """
      if (subset not in tables) or (subset not in examples_per_subset):
          raise ValueError(
              f"Invalid subset {subset!r}. "
              f"The available subsets are: {set(tables)!r}"
          )
  
      self.num_classes = num_classes
      self.base_dir = base_dir
      self.subset = subset
      self.num_examples = examples_per_subset[subset]
  
      data_relative_path = tables[subset]
      if isinstance(data_relative_path, list):
          shards = [
              os.path.join(self.base_dir, x) for x in data_relative_path
          ]
      else:
          data_path = os.path.join(self.base_dir, data_relative_path)
          shards = get_sharded_files(
              data_path=data_path,
              fraction_data=fraction_data,
              num_groups=num_groups,
              group_index=group_index,
          )
  
      super().__init__(shards=shards)
  
imports: import functools
  import os
  from typing import Dict, Iterator, List, Optional, Text, Tuple, Union
  from absl import logging
  from dmvr import builders
  from dmvr import modalities
  from dmvr import video_dataset
  from flax import jax_utils
  import jax
  import jax.numpy
  import ml_collections
  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.vivit.data import file_utils
  import tensorflow
label_desc: Use image node_id 1 to create a new TFRecordDatasetFactory object from inherited base classes: video_dataset with example: obj = TFRecordDatasetFactory(base_dir, tables, examples_per_subset, num_classes, subset, fraction_data, num_groups, group_index)