code: def computeAccuracyEnding(predictions, truths, iterations,
                      resets=None, randoms=None, num=None,
                      sequenceCounter=None):
    
    accuracy = []
    numIteration = []
    numSequences = []
  
    for i in xrange(len(predictions) - 1):
      if num is not None and i > num:
        continue
  
      if truths[i] is None:
        continue
  
      # identify the end of sequence
      if resets is not None or randoms is not None:
        if not (resets[i+1] or randoms[i+1]):
          continue
  
      correct = truths[i] is None or truths[i] in predictions[i]
      accuracy.append(correct)
      numSequences.append(sequenceCounter[i])
      numIteration.append(iterations[i])
  
    return (accuracy, numIteration, numSequences)
docs: Compute accuracy on the sequence ending