def download_pretrained_from_s3(
        location: S3Location,
        auth: Optional[S3Auth] = None,
        download_dir: Optional[str] = None
) -> str:
    """Downloads a pretrained model from S3, if it doesn't exist locally. The basename of the object's
    key is used for the filename.

    Args:
        location: Bucket and key of model file to be downloaded
        auth: AWS IAM access keys to a user with access to the model to be downloaded
        download_dir: the location where the model should be stored

    Returns:
        Path to the downloaded model
    """
    if check_s3_model_already_exists(location=location, download_dir=download_dir):
        # TODO: check if abs path is even the most appropriate???
        return get_s3_model_absolute_cache_path(location=location, download_dir=download_dir)

    url = get_presigned_s3_url(location=location, auth=auth)

    try:
        return download_pretrained_from_url(
            url=url, cache_dir=download_dir,
            cache_file_name=get_s3_model_cache_filename(location)
        )
    except HTTPError as e:
        if e.code == 403:
            # TODO: add link to auth docs
            raise ModelDownloadError(
                "Received 403 error when trying to retrieve model from s3 storage. "
                "Please check the request's s3 credentials and try again. "
            ) from e
        else:
            raise e
Downloads a pretrained model from S3, if it doesn't exist locally. The basename of the object's
    key is used for the filename.

    Args:
        location: Bucket and key of model file to be downloaded
        auth: AWS IAM access keys to a user with access to the model to be downloaded
        download_dir: the location where the model should be stored

    Returns:
        Path to the downloaded model
    
src/marqo/inference/model_download/model_download.py