code: def make_score_fn():
      """Returns a groupwise score fn to build `EstimatorSpec`."""
  
      def _score_fn(
          unused_context_features,
          group_features,
          mode,
          unused_params,
          unused_config,
      ):
          """Defines the network to score a group of documents."""
          with tf.compat.v1.name_scope("input_layer"):
              group_input = [
                  tf.compat.v1.layers.flatten(group_features[name])
                  for name in sorted(example_feature_columns())
              ]
              input_layer = tf.concat(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 = tf.compat.v1.layers.batch_normalization(
              input_layer, training=is_training
          )
          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
              )
              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(
              cur_layer, rate=FLAGS.dropout_rate, training=is_training
          )
          logits = tf.compat.v1.layers.dense(
              cur_layer, units=FLAGS.group_size
          )
          if _use_multi_head():
              # Duplicate the logits for both heads.
              return {_PRIMARY_HEAD: logits, _SECONDARY_HEAD: logits}
          else:
              return logits
  
      return _score_fn
  
imports: from absl import flags
  import numpy
  import six
  import tensorflow
  from tensorflow import estimator
  import tensorflow_ranking
label_desc: Use image node_id 8 for calling a global function with example usage: make_score_fn() and returns: _score_fn, dict, logits