[Fix] illegal memory access in GetInputIndices with optional inputs (#25881)
### Description
Fix illegal memory access in GetInputIndices with optional inputs
### Motivation and Context
When an input is optional, its ValueInfo may be nullptr.
The current implementation directly calls InputValueInfo->GetName(), leading to illegal memory access.
Update logic to skip optional inputs when valueInfo is nullptr .