code: def translation_x_direction(
      arr: np.array,
      perturb_baseline: Union[float, int, str, np.array],
      perturb_dx: int = 10,
      **kwargs,
  ) -> np.array:
      """
       Translate array by some given value in the x-direction, assumes image type data and channel first layout.
  
       Parameters
       ----------
       arr: np.ndarray
           Array to be perturbed.
       perturb_baseline: float, int, str, np.ndarray
          The baseline values to replace arr at indices with.
       perturb_dx: integer
          The translation length in features, e.g., pixels.
       kwargs: optional
          Keyword arguments.
  
      Returns
       -------
       arr_perturbed: np.ndarray
           The array which some of its indices have been perturbed.
      """
  
      if arr.ndim != 3:
          raise ValueError(
              "perturb func 'translation_x_direction' requires image-type data."
              "Check that this perturb_func receives a 3D array."
          )
  
      matrix = np.float32([[1, 0, perturb_dx], [0, 1, 0]])
      arr_perturbed = cv2.warpAffine(
          np.moveaxis(arr, 0, -1),
          matrix,
          (arr.shape[1], arr.shape[2]),
          borderValue=get_baseline_value(
              value=perturb_baseline,
              arr=arr,
              return_shape=(arr.shape[0]),
              **kwargs,
          ),
      )
      arr_perturbed = np.moveaxis(arr_perturbed, -1, 0)
      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 8 for calling a global function with example usage: translation_x_direction(arr, perturb_baseline, perturb_dx) and returns: arr_perturbed