Implementing padding mask on LSTM

Hi Everyone. I am wondering if there is a way to implement padding mask on LSTM? Like in this blog: How does masking work in an RNN (and variants) and why | by Borun Chowdhury Ph.D. | Towards Data Science

The main idea is that all masked values are ignored and the output and state for those time steps are just copied over from the last non-masked state.

Thank you!