Retry Merge: extract utils from check labels ptr (#94899)
Fixes #88098
This is the rebased and retry merging branch of the reverted PR: https://github.com/pytorch/pytorch/pull/94597
Pull Request resolved: https://github.com/pytorch/pytorch/pull/94899
Approved by: https://github.com/kit1980