class_docstr: Pipeline using `model.fit` to train a ranking `tf.keras.Model`.
  
  The `ModelFitPipeline` class is an abstract class inherit from
  `AbstractPipeline` to train and validate a ranking `model` with `model.fit`
  in a distributed strategy specified in hparams.
  
  To be implemented by subclasses:
  
    * `build_loss()`: Contains the logic to build a `tf.keras.losses.Loss` or a
    dict or list of `tf.keras.losses.Loss`s to be optimized in training.
    * `build_metrics()`: Contains the logic to build a list or dict of
    `tf.keras.metrics.Metric`s to monitor and evaluate the training.
    * `build_weighted_metrics()`: Contains the logic to build a list or dict of
    `tf.keras.metrics.Metric`s which will take the weights.
  
  Example subclass implementation:
  
  ```python
  class BasicModelFitPipeline(ModelFitPipeline):
  
    def build_loss(self):
      return tfr.keras.losses.get('softmax_loss')
  
    def build_metrics(self):
      return [
          tfr.keras.metrics.get(
              'ndcg', topn=topn, name='ndcg_{}'.format(topn)
          ) for topn in [1, 5, 10]
      ]
  
    def build_weighted_metrics(self):
      return [
          tfr.keras.metrics.get(
              'ndcg', topn=topn, name='weighted_ndcg_{}'.format(topn)
          ) for topn in [1, 5, 10]
      ]
  ```
class_docstr_tok: ["Pipeline","using","`","model.fit","`","to","train","a","ranking","`","tf.keras.Model","`",".","The","`","ModelFitPipeline","`","class","is","an","abstract","class","inherit","from","`","AbstractPipeline","`","to","train","and","validate","a","ranking","`","model","`","with","`","model.fit","`","in","a","distributed","strategy","specified","in","hparams",".","To","be","implemented","by","subclasses",":","*","`","build_loss","(",")","`",":","Contains","the","logic","to","build","a","`","tf.keras.losses.Loss","`","or","a","dict","or","list","of","`","tf.keras.losses.Loss","`","s","to","be","optimized","in","training",".","*","`","build_metrics","(",")","`",":","Contains","the","logic","to","build","a","list","or","dict","of","`","tf.keras.metrics.Metric","`","s","to","monitor","and","evaluate","the","training",".","*","`","build_weighted_metrics","(",")","`",":","Contains","the","logic","to","build","a","list","or","dict","of","`","tf.keras.metrics.Metric","`","s","which","will","take","the","weights",".","Example","subclass","implementation",":","``","`","python","class","BasicModelFitPipeline","(","ModelFitPipeline",")",":","def","build_loss","(","self",")",":","return","tfr.keras.losses.get","(","'softmax_loss","'",")","def","build_metrics","(","self",")",":","return","[","tfr.keras.metrics.get","(","'ndcg","'",",","topn=topn",",","name='ndcg_","{","}","'.format","(","topn",")",")","for","topn","in","[","1",",","5",",","10","]","]","def","build_weighted_metrics","(","self",")",":","return","[","tfr.keras.metrics.get","(","'ndcg","'",",","topn=topn",",","name='weighted_ndcg_","{","}","'.format","(","topn",")",")","for","topn","in","[","1",",","5",",","10","]","]","``","`"]
docstr: Initializes the instance.
  
  Args:
    model_builder: A `ModelBuilder` instance for model fit.
    dataset_builder: An `AbstractDatasetBuilder` instance to load train and
      validate datasets and create signatures for SavedModel.
    hparams: A dict containing model hyperparameters.
code: def __init__(
      self,
      model_builder: model_lib.AbstractModelBuilder,
      dataset_builder: AbstractDatasetBuilder,
      hparams: PipelineHparams,
  ):
      """Initializes the instance.
  
      Args:
        model_builder: A `ModelBuilder` instance for model fit.
        dataset_builder: An `AbstractDatasetBuilder` instance to load train and
          validate datasets and create signatures for SavedModel.
        hparams: A dict containing model hyperparameters.
      """
      self._validate_parameters(model_builder, dataset_builder)
  
      self._model_builder = model_builder
      self._dataset_builder = dataset_builder
      self._hparams = hparams
  
      self._optimizer = tf.keras.optimizers.get(
          {
              "class_name": self._hparams.optimizer,
              "config": {"learning_rate": self._hparams.learning_rate},
          }
      )
  
      self._strategy = strategy_utils.get_strategy(
          self._hparams.strategy,
          self._hparams.cluster_resolver,
          self._hparams.variable_partitioner,
          self._hparams.tpu,
      )
  
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 ModelFitPipeline object from inherited base classes: AbstractPipeline with example: obj = ModelFitPipeline(model_builder, dataset_builder, hparams)