code: def pixelate(
      x: np.ndarray, strength: float, xrange: tuple = None
  ) -> np.ndarray:
      """
      Change coarseness of pixels for an image.
  
      Parameters
      ----------
      x
          Instance to be perturbed.
      strength
          Strength of pixelation (<1). Lower is actually more pixelated.
      xrange
          Tuple with min and max data range.
  
      Returns
      -------
      Perturbed instance.
      """
      rows, cols = x.shape[:2]
  
      if not isinstance(xrange, tuple):
          xrange = (x.min(), x.max())
  
      if xrange[0] != 0 or xrange[1] != 255:
          x = (x - xrange[0]) / (xrange[1] - xrange[0]) * 255
  
      im = Image.fromarray(x.astype("uint8"), mode="RGB")
      im = im.resize(
          (int(rows * strength), int(cols * strength)), Image.BOX
      )
      im = im.resize((rows, cols), Image.BOX)
      x_pi = np.array(im, dtype=np.float32) / 255
      x_pi = x_pi * (xrange[1] - xrange[0]) + xrange[0]
      return x_pi
  
imports: import random
  from io import BytesIO
  from typing import List, Tuple, Union
  import cv2
  import numpy
  import skimage
  from alibi_detect.utils.data import Bunch
  from alibi_detect.utils.discretizer import Discretizer
  from alibi_detect.utils.distance import abdm, multidim_scaling
  from alibi_detect.utils.mapping import ohe2ord
  from PIL import Image
  from scipy.ndimage import zoom
  from scipy.ndimage.interpolation import map_coordinates
  from skimage.filters import gaussian
label_desc: Use image node_id 21 for calling a global function with example usage: pixelate(x, strength, xrange) and returns: x_pi