For training, feed your entire sequence into your RNN and you will get a similar size sequence out. Compute a loss between that output and your target  Y.
For testing, refer to the code I provided. output will be what you compare against the ground truth.