code: def _get_labels(self, element, locations, mode):
          r
          # Parse inputs
          locations = self._parse_indices(locations)
          element = self._parse_element(element=element)
          # Collect list of all pore OR throat labels
          labels = self.keys(mode='labels', element=element)
          labels.sort()
          labels = sp.array(labels)  # Convert to ND-array for following checks
          # Make an 2D array with locations in rows and labels in cols
          arr = sp.vstack([self[item][locations] for item in labels]).T
          num_hits = sp.sum(arr, axis=0)  # Number of locations with each label
          if mode in ['or', 'union', 'any']:
              temp = labels[num_hits > 0]
          elif mode in ['and', 'intersection']:
              temp = labels[num_hits == locations.size]
          elif mode in ['xor', 'exclusive_or']:
              temp = labels[num_hits == 1]
          elif mode in ['nor', 'not', 'none']:
              temp = labels[num_hits == 0]
          elif mode in ['nand']:
              temp = labels[num_hits == (locations.size - 1)]
          elif mode in ['xnor', 'nxor']:
              temp = labels[num_hits > 1]
          else:
              raise Exception('Unrecognized mode:'+str(mode))
          return PrintableList(temp)
docs: r"""
          This is the actual label getter method, but it should not be called
          directly.  Use ``labels`` instead.