code: def _selection_by_callable(self, view, num_slices, non_empty_slices):
          
  
          selected = [sl for sl in non_empty_slices
                      if self._sampler(self._get_axis(self._image, view, sl))]
  
          return selected[:num_slices]
docs: Returns all the slices selected by the given callable.