Fix gradient checkpointing bug BioGpt
# What does this PR do?
This PR fixes a bug that a user can encounter while using generate and models that use gradient_checkpointing.

Fixes issue #21737 for BioGpt.

cc @younesbelkada, @gante  
_The documentation is not available anymore as the PR was closed or merged._