docs: def keep_labels(self, labels, relabel=False):
          """
          Keep only the specified labels.
  
          Parameters
          ----------
          labels : int, array-like (1D, int)
              The label number(s) to keep.
  
          relabel : bool, optional
              If `True`, then the segmentation image will be relabeled
              such that the labels are in consecutive order starting from
              1.
  
          Examples
          --------
          >>> from photutils import SegmentationImage
          >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4],
          ...                           [0, 0, 0, 0, 0, 4],
          ...                           [0, 0, 3, 3, 0, 0],
          ...                           [7, 0, 0, 0, 0, 5],
          ...                           [7, 7, 0, 5, 5, 5],
          ...                           [7, 7, 0, 0, 5, 5]])
          >>> segm.keep_labels(labels=[5, 3])
          >>> segm.data
          array([[0, 0, 0, 0, 0, 0],
                 [0, 0, 0, 0, 0, 0],
                 [0, 0, 3, 3, 0, 0],
                 [0, 0, 0, 0, 0, 5],
                 [0, 0, 0, 5, 5, 5],
                 [0, 0, 0, 0, 5, 5]])
  
          >>> segm = SegmentationImage([[1, 1, 0, 0, 4, 4],
          ...                           [0, 0, 0, 0, 0, 4],
          ...                           [0, 0, 3, 3, 0, 0],
          ...                           [7, 0, 0, 0, 0, 5],
          ...                           [7, 7, 0, 5, 5, 5],
          ...                           [7, 7, 0, 0, 5, 5]])
          >>> segm.keep_labels(labels=[5, 3], relabel=True)
          >>> segm.data
          array([[0, 0, 0, 0, 0, 0],
                 [0, 0, 0, 0, 0, 0],
                 [0, 0, 1, 1, 0, 0],
                 [0, 0, 0, 0, 0, 2],
                 [0, 0, 0, 2, 2, 2],
                 [0, 0, 0, 0, 2, 2]])
          """
  
          self.check_labels(labels)
  
          labels = np.atleast_1d(labels)
          labels_tmp = list(set(self.labels) - set(labels))
          self.remove_labels(labels_tmp, relabel=relabel)