<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def labels(self, pores=[], throats=[], element=None, mode='union'):
 r""" Returns a list of labels present on the object Additionally, this function can return labels applied to a specified set of pores or throats Parameters element : string Controls whether pore or throat labels are returned. If empty then both are returned (default). pores (or throats) : array_like The pores (or throats) whose labels are sought. If left empty a list containing all pore and throat labels is returned. mode : string, optional Controls how the query should be performed. Only applicable when ``pores`` or ``throats`` are specified: **'or', 'union', 'any'**: (default) Returns the labels that are assigned to *any* of the given locations. **'and', 'intersection', 'all'**: Labels that are present on *all* the given locations. **'xor', 'exclusive_or'** : Labels that are present on *only one* of the given locations. **'nor', 'none', 'not'**: Labels that are *not* present on any of the given locations. **'nand'**: Labels that are present on *all but one* of the given locations **'xnor'**: Labels that are present on *more than one* of the given locations. 'nxor' is also accepted. Returns ------- A list containing the labels on the object. If ``pores`` or ``throats`` are given, the results are filtered according to the specified ``mode``. See Also -------- props keys Notes ----- Technically, *'nand'* and *'xnor'* should also return pores with *none* of the labels but these are not included. This makes the returned list more useful. Examples -------- ['pore.all', 'pore.front', 'pore.internal', 'pore.surface'] """

        # Short-circuit query when no pores or throats are given
        if (sp.size(pores) == 0) and (sp.size(throats) == 0):
            labels = PrintableList(self.keys(element=element, mode='labels'))
        elif (sp.size(pores) > 0) and (sp.size(throats) > 0):
            raise Exception('Cannot perform label query on pores and ' +
                            'throats simultaneously')
        elif sp.size(pores) > 0:
            labels = self._get_labels(element='pore', locations=pores,
                                      mode=mode)
        elif sp.size(throats) > 0:
            labels = self._get_labels(element='throat', locations=throats,
                                      mode=mode)
        return labels