class_docstr: Implementation of the Knockoff Nets attack from Orekondy et al. (2018).
  
  | Paper link: https://arxiv.org/abs/1812.02766
docstr: Sample data with a specific action.
  
  :param x: An array with the source input to the victim classifier.
  :param y: Target values (class labels) one-hot-encoded of shape (nb_samples, nb_classes) or indices of shape
            (nb_samples,).
  :param action: The action index returned from the action sampling.
  :return: An array with one input to the victim classifier.
docstr_tok: ["Sample","data","with","a","specific","action",".",":","param","x",":","An","array","with","the","source","input","to","the","victim","classifier",".",":","param","y",":","Target","values","(","class","labels",")","one-hot-encoded","of","shape","(","nb_samples",",","nb_classes",")","or","indices","of","shape","(","nb_samples",",",")",".",":","param","action",":","The","action","index","returned","from","the","action","sampling",".",":","return",":","An","array","with","one","input","to","the","victim","classifier","."]
code: def _sample_data(
      x: np.ndarray, y: np.ndarray, action: int
  ) -> np.ndarray:
      """
      Sample data with a specific action.
  
      :param x: An array with the source input to the victim classifier.
      :param y: Target values (class labels) one-hot-encoded of shape (nb_samples, nb_classes) or indices of shape
                (nb_samples,).
      :param action: The action index returned from the action sampling.
      :return: An array with one input to the victim classifier.
      """
      if len(y.shape) == 2:
          y_index = np.argmax(y, axis=1)
      else:
          y_index = y
  
      x_index = x[y_index == action]
      rnd_idx = np.random.choice(len(x_index))
  
      return x_index[rnd_idx]
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, TYPE_CHECKING, Union
  import numpy
  from tqdm.auto import trange
  from art.config import ART_NUMPY_DTYPE
  from art.attacks.attack import ExtractionAttack
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification.classifier import ClassifierMixin
  from art.utils import to_categorical
label_desc: Use image node_id 7 for calling the KnockoffNets obj's underlying member method code with example usage: obj._sample_data(x, y, action) and returns: x_index