Add all_paths utility function (#65602)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/65602
Test Plan: Imported from OSS
Reviewed By: suo
Differential Revision: D31163681
Pulled By: tugsbayasgalan
fbshipit-source-id: fa0b28b1d3b73efcc7671698a613e695a01cc103