def _clean_backend_id(self, backend_id):
        try:
            backend_id = int(backend_id)
        except (__HOLE__, TypeError):
            raise ValidationError(_("Invalid Backend Specified."))

        try:
            backend = SQLMobileBackend.load(backend_id)
        except:
            raise ValidationError(_("Invalid Backend Specified."))

        if (
            backend.deleted or
            not backend.is_global or
            backend.backend_type != SQLMobileBackend.SMS
        ):
            raise ValidationError(_("Invalid Backend Specified."))

        return backend_id
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/sms/forms.py/BackendMapForm._clean_backend_id