<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def send_message( self, title=None, body=None, icon=None, data=None, sound=None, badge=None, api_key=None, **kwargs):
 """ Send notification for all active devices in queryset and deactivate if DELETE_INACTIVE_DEVICES setting is set to True. """

        if self:
            from .fcm import fcm_send_bulk_message

            registration_ids = list(self.filter(active=True).values_list(
                'registration_id',
                flat=True
            ))
            if len(registration_ids) == 0:
                return [{'failure': len(self), 'success': 0}]

            result = fcm_send_bulk_message(
                registration_ids=registration_ids,
                title=title,
                body=body,
                icon=icon,
                data=data,
                sound=sound,
                badge=badge,
                api_key=api_key,
                **kwargs
            )

            self._deactivate_devices_with_error_results(
                registration_ids,
                result['results']
            )
            return result