[fix] composite compliance: margin_ranking_loss, hinge_embedding_loss (#78935)
Ref: #69991
Cause of failure is similar to the one discussed for fixing forward_ad of `nn.functional.linear`: https://github.com/pytorch/pytorch/pull/77950#discussion_r878328822
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78935
Approved by: https://github.com/zou3519