code: def _continue_search(self, state):
      
      i = state[_StateKeys.CUR_INDEX]
      alive_log_probs = state[_StateKeys.ALIVE_LOG_PROBS]
      finished_scores = state[_StateKeys.FINISHED_SCORES]
      finished_flags = state[_StateKeys.FINISHED_FLAGS]
  
      not_at_max_decode_length = tf.less(i, self.max_decode_length)
  
      # Calculate largest length penalty (the larger penalty, the better score).
      max_length_norm = _length_normalization(self.alpha, self.max_decode_length)
      # Get the best possible scores from alive sequences.
      best_alive_scores = alive_log_probs[:, 0] / max_length_norm
  
      # Compute worst score in finished sequences for each batch element
      finished_scores *= tf.to_float(finished_flags)  # set filler scores to zero
      lowest_finished_scores = tf.reduce_min(finished_scores, axis=1)
  
      # If there are no finished sequences in a batch element, then set the lowest
      # finished score to -INF for that element.
      finished_batches = tf.reduce_any(finished_flags, 1)
      lowest_finished_scores += (1. - tf.to_float(finished_batches)) * -INF
  
      worst_finished_score_better_than_best_alive_score = tf.reduce_all(
          tf.greater(lowest_finished_scores, best_alive_scores)
      )
  
      return tf.logical_and(
          not_at_max_decode_length,
          tf.logical_not(worst_finished_score_better_than_best_alive_score)
      )
docs: Return whether to continue the search loop.
  
      The loops should terminate when
        1) when decode length has been reached, or
        2) when the worst score in the finished sequences is better than the best
           score in the alive sequences (i.e. the finished sequences are provably
           unchanging)
  
      Args:
        state: A dictionary with the current loop state.
  
      Returns:
        Bool tensor with value True if loop should continue, False if loop should
        terminate.