class_docstr: A class to load dataset for ranking task.
class_docstr_tok: ["A","class","to","load","dataset","for","ranking","task","."]
code: def __init__(
      self,
      params,
      context_feature_spec: FeatureSpec = None,
      example_feature_spec: FeatureSpec = None,
      label_spec: Tuple[str, tf.io.FixedLenFeature] = None,
      dataset_fn: Optional[Callable[[], tf.data.Dataset]] = None,
  ):
      self._params = params
      self._context_feature_spec = context_feature_spec or {}
      self._example_feature_spec = example_feature_spec or {}
      self._label_spec = label_spec
      self._dataset_fn = dataset_fn
      if not self._dataset_fn:
          if params.dataset_fn not in DATASET_FN_MAP:
              raise ValueError(
                  "Wrong dataset_fn: {}! Expected: {}".format(
                      params.dataset_fn, list(DATASET_FN_MAP.keys())
                  )
              )
          self._dataset_fn = DATASET_FN_MAP[params.dataset_fn]
  
imports: import dataclasses
  from typing import Callable, Dict, Mapping, 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
label_desc: Use image node_id 1 to create a new RankingDataLoader object from inherited base classes: data_loader with example: obj = RankingDataLoader(params, context_feature_spec, example_feature_spec, label_spec, dataset_fn)