code: def make_transform_fn():
      """Returns a transform_fn that converts features to dense Tensors."""
  
      def _transform_fn(features, mode):
          """Defines transform_fn."""
          if (
              mode == tf_estimator.ModeKeys.PREDICT
              and not FLAGS.listwise_inference
          ):
              # We expect tf.Example as input during serving. In this case, group_size
              # must be set to 1.
              if FLAGS.group_size != 1:
                  raise ValueError(
                      "group_size should be 1 to be able to export model, but get %s"
                      % FLAGS.group_size
                  )
              (
                  context_features,
                  example_features,
              ) = tfr.feature.encode_pointwise_features(
                  features=features,
                  context_feature_columns=context_feature_columns(),
                  example_feature_columns=example_feature_columns(),
                  mode=mode,
                  scope="transform_layer",
              )
          else:
              mask = features.pop(_MASK)
              (
                  context_features,
                  example_features,
              ) = tfr.feature.encode_listwise_features(
                  features=features,
                  context_feature_columns=context_feature_columns(),
                  example_feature_columns=example_feature_columns(),
                  mode=mode,
                  scope="transform_layer",
              )
  
              # Document interaction attention layer.
              if FLAGS.use_document_interaction:
                  training = mode == tf_estimator.ModeKeys.TRAIN
                  concat_tensor = tfr.keras.layers.ConcatFeatures()(
                      inputs=(context_features, example_features, mask)
                  )
                  din_layer = (
                      tfr.keras.layers.DocumentInteractionAttention(
                          num_heads=FLAGS.num_attention_heads,
                          head_size=FLAGS.head_size,
                          num_layers=FLAGS.num_attention_layers,
                          dropout=FLAGS.dropout_rate,
                      )
                  )
                  example_features[
                      "document_interaction_embedding"
                  ] = din_layer(
                      inputs=(concat_tensor, mask), training=training
                  )
  
          return context_features, example_features
  
      return _transform_fn
  
file_path: ranking/tensorflow_ranking/examples/tf_ranking_tfrecord.py
imports: from absl import flags
  import tensorflow
  from tensorflow import estimator
  import tensorflow_ranking
label_desc: Use image node_id 5 for calling a global function with example usage: make_transform_fn() and returns: _transform_fn, context_features,  example_features