[export] Serialize union fields with single entry dict. (#121263) (#121337)
Summary:
remove "$type" and "$value" fields, instead only serialize as {type: value} for union fields directly.
bypass-github-export-checks
Test Plan: CI
Differential Revision: D54600943
Pull Request resolved: https://github.com/pytorch/pytorch/pull/121337
Approved by: https://github.com/tugsbayasgalan