code: def _get_prediction_length(predictions_dict):
      """Returns the length of the prediction based on the index
      of the first SEQUENCE_END token.
      """
      tokens_iter = enumerate(predictions_dict["predicted_tokens"])
      return next(
          ((i + 1) for i, _ in tokens_iter if _ == "SEQUENCE_END"),
          len(predictions_dict["predicted_tokens"]),
      )
  
file_path: seq2seq/seq2seq/tasks/decode_text.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import functools
  from pydoc import locate
  import numpy
  import tensorflow
  from tensorflow import gfile
  from seq2seq.tasks.inference_task import InferenceTask, unbatch_dict
label_desc: Use image node_id 1 for calling a global function with example usage: _get_prediction_length(predictions_dict) and returns: next