code: def labels(
          self, include_missing=False, include_transforms=False, include_cat_ids=False
      ):
          
          # TODO: Having an alternate return type triggered by a flag-parameter
          # (`include_cat_ids` in this case) is poor practice. Using flags like
          # that effectively squashes what should be two methods into one.
          # Either get rid of the need for that alternate return value type or
          # create a separate method for it.
          elements = self.all_elements if include_missing else self.valid_elements
  
          include_subtotals = include_transforms and self.dimension_type != DT.CA_SUBVAR
  
          # ---items are elements or subtotals, interleaved in display order---
          interleaved_items = tuple(self._iter_interleaved_items(elements))
  
          labels = list(
              item.label
              for item in interleaved_items
              if include_subtotals or not item.is_insertion
          )
  
          if include_cat_ids:
              element_ids = tuple(
                  None if item.is_insertion else item.element_id
                  for item in interleaved_items
                  if include_subtotals or not item.is_insertion
              )
              return list(zip(labels, element_ids))
  
          return labels
docs: Return list of str labels for the elements of this dimension.
  
          Returns a list of (label, element_id) pairs if *include_cat_ids* is
          True. The `element_id` value in the second position of the pair is
          None for subtotal items (which don't have an element-id).