def convert_transformers_model(model, task=None, **kwargs):
    """Converts the given Hugging Face transformers model into a FiftyOne
    model.

    Args:
        model: a ``transformers`` model
        task (None): the task of the model. Supported values are
            ``"image-classification"``, ``"object-detection"``,
            ``"semantic-segmentation"``, and ``"depth-estimation"``.
            If not specified, the task is automatically inferred from the model

    Returns:
         a :class:`fiftyone.core.models.Model`

    Raises:
        ValueError: if the model could not be converted
    """
    model_type = get_model_type(model, task=task)

    name_or_path = model.config._name_or_path

    d = {
        "model": model,
        "name_or_path": name_or_path,
    }

    if model_type in MODEL_TYPE_TO_CONFIG_CLASS:
        config_cls = MODEL_TYPE_TO_CONFIG_CLASS[model_type]
        config = config_cls(d)
        return MODEL_TYPE_TO_MODEL_CLASS[model_type](config)

    else:
        raise ValueError(
            "Unsupported model type; cannot convert %s to a FiftyOne model"
            % model
        )
Converts the given Hugging Face transformers model into a FiftyOne
    model.

    Args:
        model: a ``transformers`` model
        task (None): the task of the model. Supported values are
            ``"image-classification"``, ``"object-detection"``,
            ``"semantic-segmentation"``, and ``"depth-estimation"``.
            If not specified, the task is automatically inferred from the model

    Returns:
         a :class:`fiftyone.core.models.Model`

    Raises:
        ValueError: if the model could not be converted
    
fiftyone/utils/transformers.py