<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_attribute_listener(self, attr_name, observer):
 """ Add an attribute listener callback. The callback function (``observer``) is invoked differently depending on the *type of attribute*. Attributes that represent sensor values or which are used to monitor connection status are updated whenever a message is received from the vehicle. Attributes which reflect vehicle "state" are only updated when their values change (for example :py:attr:`Vehicle.system_status`, :py:attr:`Vehicle.armed`, and :py:attr:`Vehicle.mode`). The callback can be removed using :py:func:`remove_attribute_listener`. .. note:: The :py:func:`on_attribute` decorator performs the same operation as this method, but with a more elegant syntax. Use ``add_attribute_listener`` by preference if you will need to remove the observer. The argument list for the callback is ``observer(object, attr_name, attribute_value)``: * ``self`` - the associated :py:class:`Vehicle`. This may be compared to a global vehicle handle to implement vehicle-specific callback handling (if needed). * ``attr_name`` - the attribute name. This can be used to infer which attribute has triggered if the same callback is used for watching several attributes. * ``value`` - the attribute value (so you don't need to re-query the vehicle object). The example below shows how to get callbacks for (global) location changes: .. code:: python #Callback to print the location in global frame def location_callback(self, attr_name, msg):
 print "Location (Global):
 ", msg #Add observer for the vehicle's current location vehicle.add_attribute_listener('global_frame', location_callback) See :ref:`vehicle_state_observe_attributes` for more information. :param String attr_name: The name of the attribute to watch (or '*' to watch all attributes). :param observer: The callback to invoke when a change in the attribute is detected. """

        listeners_for_attr = self._attribute_listeners.get(attr_name)
        if listeners_for_attr is None:
            listeners_for_attr = []
            self._attribute_listeners[attr_name] = listeners_for_attr
        if observer not in listeners_for_attr:
            listeners_for_attr.append(observer)