code: def create_ranking_model() -> tf.keras.Model:
      """Create ranking model using Functional API."""
      (
          context_keras_inputs,
          example_keras_inputs,
          mask,
      ) = create_keras_inputs()
      context_features, example_features = preprocess_keras_inputs(
          context_keras_inputs, example_keras_inputs, mask
      )
  
      (
          flattened_context_features,
          flattened_example_features,
      ) = tfr.keras.layers.FlattenList()(
          inputs=(context_features, example_features, mask)
      )
  
      # Concatenate flattened context and example features along `list_size` dim.
      context_input = [
          tf.keras.layers.Flatten()(flattened_context_features[name])
          for name in sorted(flattened_context_features)
      ]
      example_input = [
          tf.keras.layers.Flatten()(flattened_example_features[name])
          for name in sorted(flattened_example_features)
      ]
      input_layer = tf.concat(context_input + example_input, 1)
  
      # User can create a custom scoring logic as a sequence of layers.
      dnn = tf.keras.Sequential()
      # Input batch normalization.
      if FLAGS.use_batch_norm:
          dnn.add(
              tf.keras.layers.BatchNormalization(
                  momentum=FLAGS.batch_normalization_moment
              )
          )
      for layer_size in FLAGS.hidden_layer_dims:
          dnn.add(tf.keras.layers.Dense(units=layer_size))
          if FLAGS.use_batch_norm:
              dnn.add(
                  tf.keras.layers.BatchNormalization(
                      momentum=FLAGS.batch_normalization_moment
                  )
              )
          dnn.add(tf.keras.layers.Activation(activation=tf.nn.relu))
          dnn.add(tf.keras.layers.Dropout(rate=FLAGS.dropout_rate))
      dnn.add(tf.keras.layers.Dense(units=1))
  
      logits = tfr.keras.layers.RestoreList()(
          inputs=(dnn(input_layer), mask)
      )
  
      return tf.keras.Model(
          inputs=dict(
              list(context_keras_inputs.items())
              + list(example_keras_inputs.items())
              + [(_MASK, mask)]
          ),
          outputs=logits,
          name="din_ranking_model",
      )
  
file_path: ranking/tensorflow_ranking/examples/keras/antique_kpl_din.py
imports: import os
  from typing import Dict, Optional, Tuple, Union
  from absl import app
  from absl import flags
  from absl import logging
  import tensorflow
  import tensorflow_ranking
label_desc: Use image node_id 5 for calling a global function with example usage: create_ranking_model() and returns: tf