import tensorflow as tf

          tf.reverse_v2(scales_to_logits_reversed[MERGED_LOGITS_SCOPE], [2]),
          tf.shape(images)[1:3],
          scales_to_logits_reversed[MERGED_LOGITS_SCOPE].dtype)
      outputs_to_predictions[output].append(
          tf.expand_dims(tf.nn.softmax(logits_reversed), 4))

  for output in sorted(outputs_to_predictions):
    predictions = outputs_to_predictions[output]
    # Compute average prediction across different scales and flipped images.
    predictions = tf.reduce_mean(tf.concat(predictions, 4), axis=4)
    outputs_to_predictions[output] = tf.argmax(predictions, 3, output_type=tf.dtypes.int32)
    outputs_to_predictions[output + PROB_SUFFIX] = tf.nn.softmax(predictions)

  return outputs_to_predictions


def predict_labels(images, model_options):
  """Predicts segmentation labels.

  Args:
    images: A tensor of size [batch, height, width, channels].
    model_options: A ModelOptions instance to configure models.
