code: def changed_prediction_indices(
      model: ModelInterface,
      x_batch: np.ndarray,
      x_perturbed: np.ndarray,
      return_nan_when_prediction_changes: bool,
  ) -> List[int]:
      """
      Find indices in batch, for which predicted label has changed after applying perturbation.
      If metric `return_nan_when_prediction_changes` is False, will return empty list.
  
      Parameters
      ----------
      return_nan_when_prediction_changes:
          Instance attribute of perturbation metrics.
      model:
      x_batch:
          Batch of original inputs provided by user.
      x_perturbed:
          Batch of inputs after applying perturbation.
  
      Returns
      -------
  
      changed_idx:
          List of indices in batch, for which predicted label has changed afer.
  
      """
  
      if not return_nan_when_prediction_changes:
          return []
  
      labels_before = model.predict(x_batch).argmax(axis=-1)
      labels_after = model.predict(x_perturbed).argmax(axis=-1)
      changed_idx = np.reshape(
          np.argwhere(labels_before != labels_after), -1
      )
      return changed_idx.tolist()
  
file_path: Quantus/quantus/helpers/perturbation_utils.py
imports: from __future__ import annotations
  import sys
  from typing import List, TYPE_CHECKING, Callable, Mapping
  import numpy
  import functools
label_desc: Use image node_id 3 for calling a global function with example usage: changed_prediction_indices(model, x_batch, x_perturbed, return_nan_when_prediction_changes) and returns: changed_idx, list