A few fixes/updates to record_compilation_metrics (#143332)
Summary:
Mostly cosmetic, but one bug fix:
* Bug fix: Make sure compile_id is converted to a string in the compilation metrics so it's printed as, e.g., "0/1" instead of "[0, 1]"
* Sort collections in `collection_to_str`
* Print non-string elements as `"<unknown>"` instead of None (since we don't expect non-strings)
* Move the population of the legacy metrics and any pre-processing to a new factory method in CompilationMetrics
X-link: https://github.com/pytorch/pytorch/pull/143332
Approved by: https://github.com/ppanchalia
Reviewed By: jeanschmidt
Differential Revision: D67619091
Pulled By: masnesral
fbshipit-source-id: 84179dfb808de6e66c525e6e0f27781bd5f6d1bc