code: def to_image(self, shape):
          
  
          if len(shape) != 2:
              raise ValueError('input shape must have 2 elements.')
  
          image = np.zeros(shape)
  
          if self.bbox.ixmin < 0 or self.bbox.iymin < 0:
              return self._to_image_partial_overlap(image)
  
          try:
              image[self.bbox.slices] = self.data
          except ValueError:    # partial or no overlap
              image = self._to_image_partial_overlap(image)
  
          return image
docs: Return an image of the mask in a 2D array of the given shape,
          taking any edge effects into account.
  
          Parameters
          ----------
          shape : tuple of int
              The ``(ny, nx)`` shape of the output array.
  
          Returns
          -------
          result : `~numpy.ndarray`
              A 2D array of the mask.