class_docstr: Interface for ranking pipeline to train a `tf.keras.Model`.
  
  The `AbstractPipeline` class is an abstract class to train and validate a
  ranking model in tfr.keras.
  
  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.
    * `train_and_validate()`: Contrains the main training pipeline for training
    and validation.
  
  Example subclass implementation:
  
  ```python
  class BasicPipeline(AbstractPipeline):
  
    def __init__(self, model, train_data, valid_data, name=None):
      self._model = model
      self._train_data = train_data
      self._valid_data = valid_data
      self._name = name
  
    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]
      ]
  
    def train_and_validate(self, *arg, **kwargs):
      self._model.compile(
          optimizer=tf.keras.optimizers.SGD(learning_rate=0.001),
          loss=self.build_loss(),
          metrics=self.build_metrics(),
          weighted_metrics=self.build_weighted_metrics())
      self._model.fit(
          x=self._train_data,
          epochs=100,
          validation_data=self._valid_data)
  ```
class_docstr_tok: ["Interface","for","ranking","pipeline","to","train","a","`","tf.keras.Model","`",".","The","`","AbstractPipeline","`","class","is","an","abstract","class","to","train","and","validate","a","ranking","model","in","tfr.keras",".","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",".","*","`","train_and_validate","(",")","`",":","Contrains","the","main","training","pipeline","for","training","and","validation",".","Example","subclass","implementation",":","``","`","python","class","BasicPipeline","(","AbstractPipeline",")",":","def","__init__","(","self",",","model",",","train_data",",","valid_data",",","name=None",")",":","self._model","=","model","self._train_data","=","train_data","self._valid_data","=","valid_data","self._name","=","name","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","]","]","def","train_and_validate","(","self",",","*","arg",",","*","*","kwargs",")",":","self._model.compile","(","optimizer=tf.keras.optimizers.SGD","(","learning_rate=0.001",")",",","loss=self.build_loss","(",")",",","metrics=self.build_metrics","(",")",",","weighted_metrics=self.build_weighted_metrics","(",")",")","self._model.fit","(","x=self._train_data",",","epochs=100",",","validation_data=self._valid_data",")","``","`"]
docstr: Returns the loss for model.compile.
  
  Example usage:
  
  ```python
  pipeline = BasicPipeline(model, train_data, valid_data)
  loss = pipeline.build_loss()
  ```
  
  Returns:
    A `tf.keras.losses.Loss` or a dict or list of `tf.keras.losses.Loss`.
code: def build_loss(self) -> Any:
      """Returns the loss for model.compile.
  
      Example usage:
  
      ```python
      pipeline = BasicPipeline(model, train_data, valid_data)
      loss = pipeline.build_loss()
      ```
  
      Returns:
        A `tf.keras.losses.Loss` or a dict or list of `tf.keras.losses.Loss`.
      """
      raise NotImplementedError("Calling an abstract method.")
  
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 for calling the AbstractPipeline obj's underlying member method code with example usage: obj.build_loss() without return types