code: def whole_sequence_accuracy(y_true, y_pred, lengths):
      
      lengths = np.asarray(lengths)
      end = np.cumsum(lengths)
      start = end - lengths
      bounds = np.vstack([start, end]).T
  
      errors = sum(1. for i, j in bounds
                   if np.any(y_true[i:j] != y_pred[i:j]))
      return 1 - errors / len(lengths)
docs: Average accuracy measured on whole sequences.
  
      Returns the fraction of sequences in y_true that occur in y_pred without a
      single error.