def METHOD_NAME(uid):
    """
    Return user from base64 encoded ``uid``.
    """
    if uid is None:
        raise serializers.ValidationError(_("uid is required!"))
    try:
        uid = urlsafe_base64_decode(uid)
        user = User.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, User.DoesNotExist) as e:
        raise serializers.ValidationError(_("Invalid uid {uid}")) from e
    return user