code: def _overlap_slices(self, shape):
          
  
          if len(shape) != 2:
              raise ValueError('input shape must have 2 elements.')
  
          xmin = self.bbox.ixmin
          xmax = self.bbox.ixmax
          ymin = self.bbox.iymin
          ymax = self.bbox.iymax
  
          if xmin >= shape[1] or ymin >= shape[0] or xmax <= 0 or ymax <= 0:
              # no overlap of the aperture with the data
              return None, None
  
          slices_large = (slice(max(ymin, 0), min(ymax, shape[0])),
                          slice(max(xmin, 0), min(xmax, shape[1])))
  
          slices_small = (slice(max(-ymin, 0),
                                min(ymax - ymin, shape[0] - ymin)),
                          slice(max(-xmin, 0),
                                min(xmax - xmin, shape[1] - xmin)))
  
          return slices_large, slices_small
docs: Calculate the slices for the overlapping part of the bounding
          box and an array of the given shape.
  
          Parameters
          ----------
          shape : tuple of int
              The ``(ny, nx)`` shape of array where the slices are to be
              applied.
  
          Returns
          -------
          slices_large : tuple of slices
              A tuple of slice objects for each axis of the large array,
              such that ``large_array[slices_large]`` extracts the region
              of the large array that overlaps with the small array.
  
          slices_small : slice
              A tuple of slice objects for each axis of the small array,
              such that ``small_array[slices_small]`` extracts the region
              of the small array that is inside the large array.