Removes unnecessary namespace of functions used only in einsum (#84955)
This is cosmetic change that removes a few function declarations and derives values instead of hardcoding. This is step 1 in relanding a cleaner version of einsum with opt_einsum. See https://github.com/pytorch/pytorch/pull/60191
Pull Request resolved: https://github.com/pytorch/pytorch/pull/84955
Approved by: https://github.com/soulitzer