docstr: Init function.
  
  Args:
      label: label to explain
      positive_only: if True, only take superpixels that contribute to
          the prediction of the label. Otherwise, use the top
          num_features superpixels, which can be positive or negative
          towards the label
      hide_rest: if True, make the non-explanation part of the return
          image gray
      num_features: number of superpixels to include in explanation
      min_weight: TODO
  
  Returns:
      (image, mask), where image is a 3d numpy array and mask is a 2d
      numpy array that can be used with
      skimage.segmentation.mark_boundaries
docstr_tok: ["Init","function",".","Args",":","label",":","label","to","explain","positive_only",":","if","True",",","only","take","superpixels","that","contribute","to","the","prediction","of","the","label",".","Otherwise",",","use","the","top","num_features","superpixels",",","which","can","be","positive","or","negative","towards","the","label","hide_rest",":","if","True",",","make","the","non-explanation","part","of","the","return","image","gray","num_features",":","number","of","superpixels","to","include","in","explanation","min_weight",":","TODO","Returns",":","(","image",",","mask",")",",","where","image","is","a","3d","numpy","array","and","mask","is","a","2d","numpy","array","that","can","be","used","with","skimage.segmentation.mark_boundaries"]
code: def get_image_and_mask(
      self,
      label,
      positive_only=True,
      hide_rest=False,
      num_features=5,
      min_weight=0.0,
  ):
      """Init function.
  
      Args:
          label: label to explain
          positive_only: if True, only take superpixels that contribute to
              the prediction of the label. Otherwise, use the top
              num_features superpixels, which can be positive or negative
              towards the label
          hide_rest: if True, make the non-explanation part of the return
              image gray
          num_features: number of superpixels to include in explanation
          min_weight: TODO
  
      Returns:
          (image, mask), where image is a 3d numpy array and mask is a 2d
          numpy array that can be used with
          skimage.segmentation.mark_boundaries
      """
      if label not in self.local_exp:
          raise KeyError("Label not in explanation")
      segments = self.segments
      image = self.image
      exp = self.local_exp[label]
      mask = np.zeros(segments.shape, segments.dtype)
      if hide_rest:
          temp = np.zeros(self.image.shape)
      else:
          temp = self.image.copy()
      if positive_only:
          fs = [x[0] for x in exp if x[1] > 0 and x[1] > min_weight][
              :num_features
          ]
          for f in fs:
              temp[segments == f] = image[segments == f].copy()
              mask[segments == f] = 1
          return temp, mask
      else:
          for f, w in exp[:num_features]:
              if np.abs(w) < min_weight:
                  continue
              c = 0 if w < 0 else 1
              mask[segments == f] = 1 if w < 0 else 2
              temp[segments == f] = image[segments == f].copy()
              temp[segments == f, c] = np.max(image)
              for cp in [0, 1, 2]:
                  if c == cp:
                      continue
                  # temp[segments == f, cp] *= 0.5
          return temp, mask
  
file_path: tensorwatch/tensorwatch/saliency/lime/lime_image.py
imports: import copy
  from functools import partial
  import numpy
  import sklearn
  import sklearn.preprocessing
  from sklearn.utils import check_random_state
  from skimage.color import gray2rgb
  from .None import lime_base
  from .wrappers.scikit_image import SegmentationAlgorithm
label_desc: Use image node_id 2 for calling the ImageExplanation obj's underlying member method code with example usage: obj.get_image_and_mask(label, positive_only, hide_rest, num_features, min_weight) and returns: temp,  mask, temp,  mask