code: def baseline_replacement_by_indices(
      arr: np.array,
      indices: Tuple[
          slice, ...
      ],  # Alt. Union[int, Sequence[int], Tuple[np.array]],
      indexed_axes: Sequence[int],
      perturb_baseline: Union[float, int, str, np.array],
      **kwargs,
  ) -> np.array:
      """
      Replace indices in an array by a given baseline.
  
      Parameters
      ----------
      arr: np.ndarray
           Array to be perturbed.
      indices: int, sequence, tuple
          Array-like, with a subset shape of arr.
      indexed_axes: sequence
          The dimensions of arr that are indexed. These need to be consecutive,
                    and either include the first or last dimension of array.
      perturb_baseline: float, int, str, np.ndarray
          The baseline values to replace arr at indices with.
      kwargs: optional
          Keyword arguments.
  
      Returns
      -------
      arr_perturbed: np.ndarray
           The array which some of its indices have been perturbed.
      """
      indices = expand_indices(arr, indices, indexed_axes)
      baseline_shape = get_leftover_shape(arr, indexed_axes)
  
      arr_perturbed = copy.copy(arr)
  
      # Get the baseline value.
      baseline_value = get_baseline_value(
          value=perturb_baseline,
          arr=arr,
          return_shape=tuple(baseline_shape),
          **kwargs,
      )
  
      # Perturb the array.
      arr_perturbed[indices] = np.expand_dims(
          baseline_value, axis=tuple(indexed_axes)
      )
  
      return arr_perturbed
  
file_path: Quantus/quantus/functions/perturb_func.py
imports: import copy
  import random
  import warnings
  from typing import Any, Callable, Sequence, Tuple, Union, Optional
  import cv2
  import numpy
  from scipy.sparse import lil_matrix, csc_matrix
  from scipy.sparse.linalg import spsolve
  from quantus.helpers.utils import get_baseline_value, blur_at_indices, expand_indices, get_leftover_shape, offset_coordinates
label_desc: Use image node_id 2 for calling a global function with example usage: baseline_replacement_by_indices(arr, indices, indexed_axes, perturb_baseline) and returns: arr_perturbed