code: def length_penalty(sequence_lengths, penalty_factor):
      """Calculates the length penalty according to
      https://arxiv.org/abs/1609.08144
  
       Args:
        sequence_lengths: The sequence length of all hypotheses, a tensor
          of shape [beam_size, vocab_size].
        penalty_factor: A scalar that weights the length penalty.
  
      Returns:
        The length penalty factor, a tensor fo shape [beam_size].
      """
      return tf.div(
          (5.0 + tf.to_float(sequence_lengths)) ** penalty_factor,
          (5.0 + 1.0) ** penalty_factor,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from collections import namedtuple
  import numpy
  import tensorflow
  from tensorflow.python.util import nest
label_desc: Use image node_id 4 for calling a global function with example usage: length_penalty(sequence_lengths, penalty_factor) and returns: tf