Stuck with the Implementation of Deep learning model

I intend to implement the deep learning model depicted in the image below.

enter image description here

The image depicts two models in the Training phase. The output of 1ST Model (Blue rectangle) should be the input of 2ND Model (Red rectangle) (yellow rectangle). Rest, each model will train on its own gradients relative to its own losses. Note that the gradients of the second model will not pass through to the first model.

And in Testing, I want to test samples only on the second model (yellow rectangle).

How can this be implemented in TensorFlow Keras? Any examples, suggestions, or ideas would be greatly appreciated.