[rpc/distributed] eliminate code duplication in distributed/rendezvou… (#81577)
This change eliminates duplication in redundant code paths inside of distributed/rendezvous.py. Minor additional test coverage is added.
Fixes #74440
Pull Request resolved: https://github.com/pytorch/pytorch/pull/81577
Approved by: https://github.com/H-Huang