def METHOD_NAME(tmpdir, hf_tokenizer):
    # Create pretrained model
    from transformers.models.roberta import (RobertaConfig, RobertaForMaskedLM,
                                             RobertaForSequenceClassification)
    config = RobertaConfig(vocab_size=hf_tokenizer.vocab_size)
    model = RobertaForMaskedLM(config)
    pretrained_model = HuggingFaceModel(model=model,
                                        tokenizer=hf_tokenizer,
                                        task='mlm',
                                        model_dir=tmpdir,
                                        device=torch.device('cpu'))
    pretrained_model.save_checkpoint()
    # Create finetuning model
    config = RobertaConfig(vocab_size=hf_tokenizer.vocab_size,
                           problem_type='regression',
                           num_labels=1)
    model = RobertaForSequenceClassification(config)
    finetune_model = HuggingFaceModel(model=model,
                                      tokenizer=hf_tokenizer,
                                      task='regression',
                                      model_dir=tmpdir,
                                      device=torch.device('cpu'))
    # Load pretrained model
    finetune_model.load_from_pretrained()
    # check weights match
    pretrained_model_state_dict = pretrained_model.model.state_dict()
    finetune_model_state_dict = finetune_model.model.state_dict()
    pretrained_base_model_keys = [
        key for key in pretrained_model_state_dict.keys() if 'roberta' in key
    ]
    matches = [
        torch.allclose(pretrained_model_state_dict[key],
                       finetune_model_state_dict[key])
        for key in pretrained_base_model_keys
    ]
    assert all(matches)