def METHOD_NAME(self, state_dict):
    from collections import OrderedDict
    if "state_dict" in state_dict:
        state_dict = state_dict["state_dict"]
    if "model" in state_dict:  # fairseq checkpoint format.
        state_dict = state_dict["model"]
    ret_state_dict = OrderedDict()
    for (
        key,
        value,
    ) in state_dict.items():
        # remove fairseq wrapper since this is a task.
        if key.startswith("mmmodel"):
            key = key[len("mmmodel."):]
        ret_state_dict[key] = value
    return ret_state_dict