class_docstr: Builds datasets from feature specs.
  
  The `BaseDatasetBuilder` class is an abstract class inherit from
  `AbstractDatasetBuilder` to serve training and validation datasets and
  signatures for training `ModelFitPipeline`.
  
  To be implemented by subclasses:
  
    * `_features_and_labels()`: Contains the logic to map a dict of tensors of
    dataset to feature tensors and label tensors.
  
  Example subclass implementation:
  
  ```python
  class SimpleDatasetBuilder(BaseDatasetBuilder):
  
    def _features_and_labels(self, features):
      label = features.pop("utility")
      return features, label
  ```
class_docstr_tok: ["Builds","datasets","from","feature","specs",".","The","`","BaseDatasetBuilder","`","class","is","an","abstract","class","inherit","from","`","AbstractDatasetBuilder","`","to","serve","training","and","validation","datasets","and","signatures","for","training","`","ModelFitPipeline","`",".","To","be","implemented","by","subclasses",":","*","`","_features_and_labels","(",")","`",":","Contains","the","logic","to","map","a","dict","of","tensors","of","dataset","to","feature","tensors","and","label","tensors",".","Example","subclass","implementation",":","``","`","python","class","SimpleDatasetBuilder","(","BaseDatasetBuilder",")",":","def","_features_and_labels","(","self",",","features",")",":","label","=","features.pop","(","``","utility","''",")","return","features",",","label","``","`"]
docstr: Returns `tf.data.Dataset` for training or validating the model.
  
  Args:
    file_pattern: File pattern for input data.
    batch_size: Number of input examples to process per batch.
    list_size: The list size for an ELWC example.
    randomize_input: If true, randomize input example order. It should almost
      always be true except for unittest/debug purposes.
    num_epochs: Number of times the input dataset must be repeated. None to
      repeat the data indefinitely.
  
  Returns:
    A `tf.data.Dataset`.
code: def _build_dataset(
      self,
      file_pattern: str,
      batch_size: int,
      list_size: Optional[int] = None,
      randomize_input: bool = True,
      num_epochs: Optional[int] = None,
  ) -> tf.data.Dataset:
      """Returns `tf.data.Dataset` for training or validating the model.
  
      Args:
        file_pattern: File pattern for input data.
        batch_size: Number of input examples to process per batch.
        list_size: The list size for an ELWC example.
        randomize_input: If true, randomize input example order. It should almost
          always be true except for unittest/debug purposes.
        num_epochs: Number of times the input dataset must be repeated. None to
          repeat the data indefinitely.
  
      Returns:
        A `tf.data.Dataset`.
      """
      # TODO: Remove defaults common in Estimator pipeline and here.
      dataset = data.build_ranking_dataset(
          file_pattern=file_pattern,
          data_format=data.ELWC,
          batch_size=batch_size,
          list_size=list_size,
          context_feature_spec=dict(
              list(self._context_feature_spec.items())
              + list(self._training_only_context_spec.items())
          ),
          example_feature_spec=dict(
              list(self._example_feature_spec.items())
              + list(self._training_only_example_spec.items())
          ),
          mask_feature_name=self._mask_feature_name,
          reader=self._hparams.dataset_reader,
          num_epochs=num_epochs,
          shuffle=randomize_input,
          shuffle_buffer_size=1000,
          sloppy_ordering=True,
          drop_final_batch=False,
          shuffle_examples=False,
      )
  
      return dataset.map(
          self._features_and_labels,
          num_parallel_calls=tf.data.experimental.AUTOTUNE,
      )
  
imports: import abc
  import dataclasses
  import os
  from typing import Any, Dict, List, Optional, Tuple, Union
  import tensorflow
  from tensorflow_ranking.python import data
  from tensorflow_ranking.python.keras import losses
  from tensorflow_ranking.python.keras import metrics
  from tensorflow_ranking.python.keras import model
  from tensorflow_ranking.python.keras import saved_model
  from tensorflow_ranking.python.keras import strategy_utils
label_desc: Use image node_id 3 for calling the BaseDatasetBuilder obj's underlying member method code with example usage: obj._build_dataset(file_pattern, batch_size, list_size, randomize_input, num_epochs) and returns: dataset