code: def make_score_fn():
      """Returns a scoring function to build `EstimatorSpec`."""
  
      def _score_fn(
          context_features, group_features, mode, params, config
      ):
          """Defines the network to score a group of documents."""
          del [params, config]
          with tf.compat.v1.name_scope("input_layer"):
              context_input = [
                  tf.compat.v1.layers.flatten(context_features[name])
                  for name in sorted(context_feature_columns())
              ]
              group_input = [
                  tf.compat.v1.layers.flatten(group_features[name])
                  for name in sorted(
                      example_feature_columns(use_weight_feature=False)
                  )
              ]
              if FLAGS.use_document_interaction:
                  group_input.append(
                      tf.compat.v1.layers.flatten(
                          group_features[
                              "document_interaction_embedding"
                          ]
                      )
                  )
              input_layer = tf.concat(context_input + group_input, 1)
              tf.compat.v1.summary.scalar(
                  "input_sparsity", tf.nn.zero_fraction(input_layer)
              )
              tf.compat.v1.summary.scalar(
                  "input_max", tf.reduce_max(input_tensor=input_layer)
              )
              tf.compat.v1.summary.scalar(
                  "input_min", tf.reduce_min(input_tensor=input_layer)
              )
          is_training = mode == tf_estimator.ModeKeys.TRAIN
          cur_layer = input_layer
          cur_layer = tf.compat.v1.layers.batch_normalization(
              cur_layer, training=is_training, momentum=0.99
          )
  
          for i, layer_width in enumerate(
              int(d) for d in FLAGS.hidden_layer_dims
          ):
              cur_layer = tf.compat.v1.layers.dense(
                  cur_layer, units=layer_width
              )
              cur_layer = tf.compat.v1.layers.batch_normalization(
                  cur_layer, training=is_training, momentum=0.99
              )
              cur_layer = tf.nn.relu(cur_layer)
              tf.compat.v1.summary.scalar(
                  "fully_connected_{}_sparsity".format(i),
                  tf.nn.zero_fraction(cur_layer),
              )
              cur_layer = tf.compat.v1.layers.dropout(
                  inputs=cur_layer,
                  rate=FLAGS.dropout_rate,
                  training=is_training,
              )
          logits = tf.compat.v1.layers.dense(
              cur_layer, units=FLAGS.group_size
          )
          return logits
  
      return _score_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 6 for calling a global function with example usage: make_score_fn() and returns: _score_fn, logits