[from_pretrained] refactor find_mismatched_keys
This PR refactors 2 large identical code copies introduced by the recent sharded checkpoint PR into a helper function which is then called from 2 places. There is no change in functionality.

It's an intermediary step for this PR: https://github.com/huggingface/transformers/pull/16657 which revamps `low_cpu_mem_usage` and integrates it better with the sharded checkpoint code branch.

I explained here why the helper function is not a closure but needs the input args explicitly: https://github.com/huggingface/transformers/pull/16657#discussion_r846812714

@sgugger 

_The documentation is not available anymore as the PR was closed or merged._