def download_model(
        repo_location: Optional[ModelLocation] = None,
        url: Optional[str] = None,
        auth: Optional[ModelAuth] = None,
        download_dir: Optional[str] = None
    ) -> str:
    """
    Download a model from a given location.

    Args:
        repo_location: object that contains information about the location of a
            model. For example, s3 bucket and object path
        url: location of a model specified by a URL
        auth: object that contains information about authorisation required to
            download a model. For example, s3 access keys
        download_dir: The directory where the model should be downloaded.

    Returns:
        The path of the downloaded model
    """
    single_weight_location_validation_msg = (
        "only exactly one of parameters (repo_location, url) is allowed to be specified.")
    if repo_location is None and url is None:
        raise InvalidModelPropertiesError(single_weight_location_validation_msg)
    if repo_location is not None and url is not None:
        raise InvalidModelPropertiesError(single_weight_location_validation_msg)

    if url:
        return download_pretrained_from_url(url=url, cache_dir=download_dir)
    if isinstance(repo_location, ModelLocation):
        if repo_location.s3:
            download_kwargs = {'location': repo_location.s3, 'download_dir': download_dir}
            if auth is not None:
                download_kwargs['auth'] = auth.s3
            return download_pretrained_from_s3(**download_kwargs)
        elif repo_location.hf:
            download_kwargs = {'location': repo_location.hf, 'download_dir': download_dir}
            if auth is not None:
                download_kwargs['auth'] = auth.hf
            return download_model_from_hf(**download_kwargs)
    else:
        raise InternalError("Invalid model location object provided.")

    Download a model from a given location.

    Args:
        repo_location: object that contains information about the location of a
            model. For example, s3 bucket and object path
        url: location of a model specified by a URL
        auth: object that contains information about authorisation required to
            download a model. For example, s3 access keys
        download_dir: The directory where the model should be downloaded.

    Returns:
        The path of the downloaded model
    
src/marqo/inference/model_download/model_download.py