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: Intializes the instance.
  
  Args:
    context_feature_spec: Maps context (aka, query) names to feature specs.
    example_feature_spec: Maps example (aka, document) names to feature specs.
    training_only_example_spec: Feature specs used for training only like
      labels and per-example weights.
    mask_feature_name: If set, populates the feature dictionary with this name
      and the coresponding value is a `tf.bool` Tensor of shape [batch_size,
      list_size] indicating the actual example is padded or not.
    hparams: A dict containing model hyperparameters.
    training_only_context_spec: Feature specs used for training only per-list
      weights.
code: def __init__(
      self,
      context_feature_spec: Dict[
          str,
          Union[
              tf.io.FixedLenFeature,
              tf.io.VarLenFeature,
              tf.io.RaggedFeature,
          ],
      ],
      example_feature_spec: Dict[
          str,
          Union[
              tf.io.FixedLenFeature,
              tf.io.VarLenFeature,
              tf.io.RaggedFeature,
          ],
      ],
      training_only_example_spec: Dict[
          str,
          Union[
              tf.io.FixedLenFeature,
              tf.io.VarLenFeature,
              tf.io.RaggedFeature,
          ],
      ],
      mask_feature_name: str,
      hparams: DatasetHparams,
      training_only_context_spec: Optional[
          Dict[
              str,
              Union[
                  tf.io.FixedLenFeature,
                  tf.io.VarLenFeature,
                  tf.io.RaggedFeature,
              ],
          ]
      ] = None,
  ):
      """Intializes the instance.
  
      Args:
        context_feature_spec: Maps context (aka, query) names to feature specs.
        example_feature_spec: Maps example (aka, document) names to feature specs.
        training_only_example_spec: Feature specs used for training only like
          labels and per-example weights.
        mask_feature_name: If set, populates the feature dictionary with this name
          and the coresponding value is a `tf.bool` Tensor of shape [batch_size,
          list_size] indicating the actual example is padded or not.
        hparams: A dict containing model hyperparameters.
        training_only_context_spec: Feature specs used for training only per-list
          weights.
      """
      self._context_feature_spec = context_feature_spec
      self._example_feature_spec = example_feature_spec
      self._training_only_example_spec = training_only_example_spec
      self._mask_feature_name = mask_feature_name
      self._hparams = hparams
      self._training_only_context_spec = (
          training_only_context_spec or {}
      )
  
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 1 to create a new BaseDatasetBuilder object from inherited base classes: AbstractDatasetBuilder with example: obj = BaseDatasetBuilder(context_feature_spec, example_feature_spec, training_only_example_spec, mask_feature_name, hparams, training_only_context_spec)