To my understanding , in the following snapshot, the $$i$$-th example is a tuple that looks like $$(\mathbf{x}^{(i)}, \mathbf{y}^{(i)}):=(\{\mathbf{x}^{(i)<1>},\cdots, \mathbf{x}^{(i)}\}, \{\mathbf{y}^{(i)<1>},\cdots, \mathbf{y}^{(i)}\})$$ where $$T_x^{}$$ and $$T_y^{}$$ are not necessarily equal. The $$\mathbf{x}^{(i)}$$'s are fed into RNN units and we get prediction $$\hat{\mathbf{y}}^{(i)}$$'s. Suppose there are $$m$$ examples in total, the loss should actually be $$\ell = \sum_{i=1}^m\sum_{t=1}^{T_y^{(i)}} \ell(\hat{\mathbf{y}}^{(i)}, \mathbf{y}^{(i)})$$ which seems not to be consistent with Andrew's notation. In his notation, the loss of each individual RNN unit seems to be different (therefore he has $$\ell^{}(\cdot)$$ instead of generic $$\ell(\cdot)$$).