[FSDP] Use state_dict hook to save shard metadata for consolidating checkpoint (#4572)
* use state_dict hook to save shard metadata
* Revert "use state_dict hook to save shard metadata"
This reverts commit d696ce37adbf3dd43dc4691487af356c16b79b3b.
* use remove_duplicate to support module reuse
* applying format