class_docstr: Builds datasets for multi-task training.
  
  This supports a single data sets with multiple labels formed in a dict. The
  case where we have multiple datasets is not handled in the current code yet.
  We can consider to extend the dataset builder when the use case comes out.
  
  Example usage:
  
  ```python
  context_feature_spec = {}
  example_feature_spec = {
      "example_feature_1": tf.io.FixedLenFeature(
          shape=(1,), dtype=tf.float32, default_value=0.0)
  }
  mask_feature_name = "list_mask"
  label_spec_tuple = ("utility",
                      tf.io.FixedLenFeature(
                          shape=(1,),
                          dtype=tf.float32,
                          default_value=_PADDING_LABEL))
  label_spec = {"task1": label_spec_tuple, "task2": label_spec_tuple}
  weight_spec = ("weight",
                 tf.io.FixedLenFeature(
                     shape=(1,), dtype=tf.float32, default_value=1.))
  dataset_hparams = DatasetHparams(
      train_input_pattern="train.dat",
      valid_input_pattern="valid.dat",
      train_batch_size=128,
      valid_batch_size=128)
  dataset_builder = MultiLabelDatasetBuilder(
      context_feature_spec,
      example_feature_spec,
      mask_feature_name,
      label_spec,
      dataset_hparams,
      sample_weight_spec=weight_spec)
  ```
class_docstr_tok: ["Builds","datasets","for","multi-task","training",".","This","supports","a","single","data","sets","with","multiple","labels","formed","in","a","dict",".","The","case","where","we","have","multiple","datasets","is","not","handled","in","the","current","code","yet",".","We","can","consider","to","extend","the","dataset","builder","when","the","use","case","comes","out",".","Example","usage",":","``","`","python","context_feature_spec","=","{","}","example_feature_spec","=","{","``","example_feature_1","''",":","tf.io.FixedLenFeature","(","shape=","(","1",",",")",",","dtype=tf.float32",",","default_value=0.0",")","}","mask_feature_name","=","``","list_mask","''","label_spec_tuple","=","(","``","utility","''",",","tf.io.FixedLenFeature","(","shape=","(","1",",",")",",","dtype=tf.float32",",","default_value=_PADDING_LABEL",")",")","label_spec","=","{","``","task1","''",":","label_spec_tuple",",","``","task2","''",":","label_spec_tuple","}","weight_spec","=","(","``","weight","''",",","tf.io.FixedLenFeature","(","shape=","(","1",",",")",",","dtype=tf.float32",",","default_value=1",".",")",")","dataset_hparams","=","DatasetHparams","(","train_input_pattern=","''","train.dat","''",",","valid_input_pattern=","''","valid.dat","''",",","train_batch_size=128",",","valid_batch_size=128",")","dataset_builder","=","MultiLabelDatasetBuilder","(","context_feature_spec",",","example_feature_spec",",","mask_feature_name",",","label_spec",",","dataset_hparams",",","sample_weight_spec=weight_spec",")","``","`"]
docstr: See `BaseDatasetBuilder`.
code: def _features_and_labels(
      self, features: Dict[str, tf.Tensor]
  ) -> Union[
      Tuple[Dict[str, tf.Tensor], Dict[str, tf.Tensor]],  #
      Tuple[Dict[str, tf.Tensor], Dict[str, tf.Tensor], tf.Tensor],
  ]:
      """See `BaseDatasetBuilder`."""
      to_pop = set()
      label = {}
      for task_name, (feature_name, _) in self._label_spec.items():
          label[task_name] = _convert_label(
              features[feature_name],
              self._hparams.convert_labels_to_binary,
          )
          to_pop.add(feature_name)
  
      if self._sample_weight_spec:
          feature_name, _ = self._sample_weight_spec
          weight = tf.cast(
              tf.squeeze(features[feature_name], 2), tf.float32
          )
          to_pop.add(feature_name)
      else:
          weight = None
  
      for name in to_pop:
          features.pop(name)
  
      if weight is None:
          return features, label
      else:
          return features, label, weight
  
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 2 for calling the MultiLabelDatasetBuilder obj's underlying member method code with example usage: obj._features_and_labels(features) and returns: features,  label, features,  label,  weight