Small clean up generate
# What does this PR do?

This PR does a small clean-up for PyTorch's generate by removing unused duplicated code and ordering the code a bit better.
_The documentation is not available anymore as the PR was closed or merged._