When does the third conditional branch of the project function that generates hidden_states→query,value in T5 work?

It is unclear when the modeling_t5.py’s conditional branch on line 488 is executed.
The key_value_states, which is the first and second conditional branch, will contain the final output of the encoder at cross attention. Thus, we can see that it will be None otherwise, like the encoder’s forward.

I understand that the last hidden_states = past_key_value is a cache to omit the calculation during autoregressive.

What, then, does the conditional branch 488 and concatinate on line 491 do?