def METHOD_NAME(
    display_name: Optional[str],
    identifier: str,
    size: Optional[int] = None,
    try_gravatar: Optional[bool] = True,
) -> str:
    if try_gravatar:
        try:
            validate_email(identifier)
        except ValidationError:
            pass
        else:
            try:
                resp = safe_urlopen(get_gravatar_url(identifier, default=404))
            except Exception:
                pass
            else:
                if resp.status_code == 200:
                    # default to mm if including in emails
                    gravatar_url = get_gravatar_url(identifier, size=size)
                    return f'<img class="avatar" src="{gravatar_url}">'
    return get_letter_avatar(display_name, identifier, size, use_svg=False)