Fix BeamSearch T5 if initializers are on outer scope (#23044)
### Description
This PR adds the logic needed to consider only the needed implicit
inputs on BeamSearch op in case of T5 model (encoder/decoder, 2 graphs).
The logic added is similar to what happens in the _If_ kernel setup.
### Motivation and Context
Fixes #23043