code: def _sample_grid(
      x: np.ndarray,
      feature_range: np.ndarray,
      epsilon: float = 0.04,
      nb_samples: int = 10,
      res: int = 100,
  ) -> np.ndarray:
      """Samples data points uniformly from an interval centered at `x` and with size `epsilon * delta`,
      with `delta = f_max - f_min` the features ranges.
  
      Parameters
      ----------
      x
          Instance of interest.
      feature_range
          Array with min and max values for each feature.
      epsilon
          Size of the sampling region around central instance as percentage of features range.
      nb_samples
          Number of samples to generate.
  
      Returns
      -------
      Sampled vectors.
  
      """
      nb_instances = x.shape[0]
      x = x.reshape(x.shape[0], -1)
      dim = x.shape[1]  # number of features
  
      size = np.round(epsilon * res).astype(int)
      if size <= 2:
          size = 2
  
      deltas = np.abs(
          feature_range[:, 1] - feature_range[:, 0]
      ) / float(
          res
      )  # shape=(nb_features)
  
      rnd_sign = (
          2
          * (np.random.randint(2, size=(nb_instances, nb_samples, dim)))
          - 1
      )
      rnd = (
          np.random.randint(size, size=(nb_instances, nb_samples, dim))
          + 1
      )
      rnd = (
          rnd_sign * rnd
      )  # shape=(nb_instances, nb_samples, nb_features)
  
      vprime = rnd * deltas
      X_sampled = (
          x.reshape(x.shape[0], 1, x.shape[1]) + vprime
      )  # shape=(nb_instances, nb_samples, nb_features)
  
      return X_sampled
  
file_path: alibi/alibi/confidence/model_linearity.py
imports: import logging
  import string
  from time import time
  from typing import Callable, List, Optional, Tuple, Union
  import numpy
  from numpy.linalg import norm
  from sklearn.neighbors import NearestNeighbors
label_desc: Use image node_id 5 for calling a global function with example usage: _sample_grid(x, feature_range, epsilon, nb_samples, res) and returns: X_sampled