code: def _get_segments_felzenszwalb(
      im, resize_image=True, scale_range=None, dilation_rad=5
  ):
      """Compute image segments based on Felzenszwalb's algorithm.
  
      Efficient graph-based image segmentation, Felzenszwalb, P.F.
      and Huttenlocher, D.P. International Journal of Computer Vision, 2004
  
      Args:
        im: Input image.
        resize_image: If True, the image is resized to 224,224 for the segmentation
                      purposes. The resulting segments are rescaled back to match
                      the original image size. It is done for consistency w.r.t.
                      segmentation parameter range. Defaults to True.
        scale_range:  Range of image values to use for segmentation algorithm.
                      Segmentation algorithm is sensitive to the input image
                      values, therefore we need to be consistent with the range
                      for all images. If None is passed, the range is scaled to
                      [-1.0, 1.0]. Defaults to None.
        dilation_rad: Sets how much each segment is dilated to include edges,
                      larger values cause more blobby segments, smaller values
                      get sharper areas. Defaults to 5.
      Returns:
          masks: A list of boolean masks as np.ndarrays if size HxW for im size of
                 HxWxC.
      """
  
      # TODO (tolgab) Set this to default float range of 0.0 - 1.0 and tune
      # parameters for that
      if scale_range is None:
          scale_range = _FELZENSZWALB_IM_VALUE_RANGE
      # Normalize image value range and size
      original_shape = im.shape[:2]
      # TODO (tolgab) This resize is unnecessary with more intelligent param range
      # selection
      if resize_image:
          im = _normalize_image(
              im, scale_range, _FELZENSZWALB_IM_RESIZE
          )
      else:
          im = _normalize_image(im, scale_range)
      segs = []
      for scale in _FELZENSZWALB_SCALE_VALUES:
          for sigma in _FELZENSZWALB_SIGMA_VALUES:
              seg = segmentation.felzenszwalb(
                  im,
                  scale=scale,
                  sigma=sigma,
                  min_size=_FELZENSZWALB_MIN_SEGMENT_SIZE,
              )
              if resize_image:
                  seg = resize(
                      seg,
                      original_shape,
                      order=0,
                      preserve_range=True,
                      mode="constant",
                      anti_aliasing=False,
                  ).astype(int)
              segs.append(seg)
      masks = _unpack_segs_to_masks(segs)
      if dilation_rad:
          selem = disk(dilation_rad)
          masks = [dilation(mask, selem=selem) for mask in masks]
      return masks
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import logging
  from .base import CoreSaliency
  from .integrated_gradients import IntegratedGradients
  import numpy
  from skimage import segmentation
  from skimage.morphology import dilation
  from skimage.morphology import disk
  from skimage.transform import resize
label_desc: Use image node_id 2 for calling a global function with example usage: _get_segments_felzenszwalb(im, resize_image, scale_range, dilation_rad) and returns: masks