code: def rounding_sequence_accuracy(
      predictions, labels, weights_fn=common_layers.weights_nonzero
  ):
      """Sequence accuracy for L1/L2 losses: round down the predictions to ints."""
      outputs = tf.squeeze(tf.to_int32(predictions), axis=-1)
      weights = weights_fn(labels)
      labels = tf.to_int32(labels)
      not_correct = tf.to_float(tf.not_equal(outputs, labels)) * weights
      axis = list(range(1, len(outputs.get_shape())))
      correct_seq = 1.0 - tf.minimum(
          1.0, tf.reduce_sum(not_correct, axis=axis)
      )
      return correct_seq, tf.constant(1.0)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import six
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import modalities
  from tensor2tensor.utils import bleu_hook
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import rouge
  from tensor2tensor.utils import sari_hook
  import tensorflow.compat.v1
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 9 for calling a global function with example usage: rounding_sequence_accuracy(predictions, labels, weights_fn) and returns: correct_seq,  tf