extract calculate_time_spent from print_time_report (#127362)
Summary:
Fixes #ISSUE_NUMBER
wrap certain steps in a separate function for easier TTFB instrumentation (fb internal use case)
X-link: https://github.com/pytorch/pytorch/pull/127362
Approved by: https://github.com/yanboliang, https://github.com/mengluy0125
Reviewed By: yanboliang, PaliC, mengluy0125
Differential Revision: D57889404
Pulled By: dshi7
fbshipit-source-id: d87091f0f1470c6235f532050f7d61edd0d43878