code: def test_mutate(mutate_params):
      rate, x_mutate, feature_range = mutate_params
      x_pert = mutate_categorical(
          x_mutate, rate, feature_range=feature_range
      ).numpy()
      delta = ((x_mutate - x_pert) != 0).astype(int)
      eps = rate * 0.5
      assert (
          rate - eps
          <= delta.sum() / np.prod(x_mutate.shape)
          <= rate + eps
      )
      if rate > 0.0:
          assert (
              x_pert.min() == feature_range[0]
              and x_pert.max() == feature_range[1]
          )
  
file_path: alibi-detect/alibi_detect/utils/tests/test_perturbation.py
imports: from functools import reduce
  from itertools import product
  from operator import mul
  import numpy
  import pytest
  from alibi_detect.utils.data import Bunch
  from alibi_detect.utils.perturbation import apply_mask, inject_outlier_ts
  from alibi_detect.utils.tensorflow.perturbation import mutate_categorical
label_desc: Use image node_id 6 for calling a global function with example usage: test_mutate(mutate_params) without return types