def _remove_model_weights(model: dict, to_delete=None) -> dict:
    """
    Removes certain weights of a given model. The weights to remove are given by the to_delete argument.
    If there is also a bias term, that is deleted as well.
    Args:
        model: Loaded detectron2 model
        to_delete (list): Names of the weights to delete from the model, by default:
                     ['roi_heads.box_predictor.cls_score',
                      'roi_heads.box_predictor.bbox_pred']
    """
    assert isinstance(model, dict)
    assert 'model' in model

    # print("Removing model weights with to_delete = None\n It is recommended to specify the to_delete weights directly, or use remove_model_weights_fsdet etc")

    # to_delete default values written here in order for default args to be immutable.
    if to_delete is None:
        # Heads in the bbox predictor:
        to_delete = ['roi_heads.box_predictor.cls_score',
                     'roi_heads.box_predictor.bbox_pred']

    for param_name in to_delete:
        del model['model'][param_name + '.weight']
        if param_name + '.bias' in model['model']:
            del model['model'][param_name + '.bias']

    return model