Validate MaxpoolWithMask kernel rank matches input spatial rank (#29253)
### Description
`MaxpoolWithMask::Compute` now validates that the pooling kernel rank
equals the input spatial rank (and that the rank is one of the supported
values {1, 2, 3}) before allocating the output, returning a clear error
for malformed inputs instead of proceeding with a mismatched
configuration.
### Changes
- Add an explicit check in `MaxpoolWithMask::Compute` that the kernel
rank matches the input spatial rank and is within the supported {1, 2,
3} range, with a descriptive error message.
- DRY up the rank check.
- Add `MaxPoolWithMask_KernelRankMismatch` and
`MaxPoolWithMask_KernelRankTooLarge` unit tests covering the new
validation.
### Motivation
Improves input validation and error diagnostics for malformed
`MaxpoolWithMask` inputs. CPU-only; no behavior change for valid inputs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>