import torch


def _find_mismatch_sizes(model: torch.nn.Module, state_dict):
    """Finds the keys in the state_dict that are different from the model.

    Args:
        model (torch.nn.Module): The model to load weights into.
        state_dict (dict): The state_dict to load.

    Returns:
        list[str]: The list of keys that are different from the model.
    """
    params_shape_mismatch = set()
    for source in [model.state_dict().items(), model.named_parameters()]:
        for name, param in source:
            if name not in state_dict:
                continue
            if param.shape != state_dict[name].shape:
                params_shape_mismatch |= {name}

    return list(params_shape_mismatch)