code: def _make_dnn_score_fn(
      hidden_units,
      activation_fn=tf.nn.relu,
      dropout=None,
      use_batch_norm=False,
      batch_norm_moment=0.999,
  ):
      """Returns a DNN scoring fn that outputs a score per example.
  
      Args:
        hidden_units: (list) Iterable of number hidden units per layer for a DNN
          model. All layers are fully connected. Ex. `[64, 32]` means first layer
          has 64 nodes and second one has 32.
        activation_fn: Activation function applied to each layer. If `None`, will
          use `tf.nn.relu`.
        dropout: (float) When not `None`, the probability we will drop out a given
          coordinate.
        use_batch_norm: (bool) If true, use batch normalization after each hidden
          layer.
        batch_norm_moment: (float) Momentum for the moving average in batch
          normalization.
  
      Returns:
        A DNN scoring function.
      """
      activation_fn = activation_fn or tf.nn.relu
  
      def _scoring_function(context_features, example_features, mode):
          """Defines the DNN-based scoring fn.
  
          Args:
            context_features: (dict) A mapping from context feature names to dense 2-D
              Tensors of shape [batch_size, ...].
            example_features: (dict) A mapping from example feature names to dense 3-D
              Tensors of shape [batch_size, list_size, ...].
            mode: (`tf.estimator.ModeKeys`) TRAIN, EVAL, or PREDICT.
  
          Returns:
            A Tensor of shape [batch_size, 1] containing per-example.
            scores.
          """
          # Input layer.
          with tf.compat.v1.name_scope("input_layer"):
              example_input = [
                  tf.compat.v1.layers.flatten(example_features[name])
                  for name in sorted(list(example_features.keys()))
              ]
              context_input = [
                  tf.compat.v1.layers.flatten(context_features[name])
                  for name in sorted(list(context_features.keys()))
              ]
              # Concat context and example features as input.
              input_layer = tf.concat(context_input + example_input, 1)
  
          is_training = mode == tf_estimator.ModeKeys.TRAIN
          cur_layer = input_layer
          # Construct a deep neural network model.
          with tf.compat.v1.name_scope("dnn_model"):
              if use_batch_norm:
                  cur_layer = tf.compat.v1.layers.batch_normalization(
                      cur_layer,
                      training=is_training,
                      momentum=batch_norm_moment,
                  )
              logits = _feed_forward_network(
                  cur_layer,
                  map(int, hidden_units),
                  output_units=1,
                  activation_fn=activation_fn,
                  batch_norm=use_batch_norm,
                  batch_norm_moment=batch_norm_moment,
                  dropout=dropout,
                  is_training=is_training,
              )
  
          tf.compat.v1.summary.scalar(
              "logits_mean", tf.reduce_mean(input_tensor=logits)
          )
          return logits
  
      return _scoring_function
  
imports: import tensorflow
  from tensorflow import estimator
  from tensorflow.python.util import function_utils
  from tensorflow_ranking.python import feature
  from tensorflow_ranking.python import head
  from tensorflow_ranking.python import losses
  from tensorflow_ranking.python import metrics
  from tensorflow_ranking.python import model
  from tensorflow_ranking.python import utils
label_desc: Use image node_id 4 for calling a global function with example usage: _make_dnn_score_fn(hidden_units, activation_fn, dropout, use_batch_norm, batch_norm_moment) and returns: _scoring_function, logits