code: def _slice_by_classification_correctness(
      data: AttackInputData,
      correctly_classified: bool,
      return_slice_indices: bool = False,
  ) -> AttackInputData:
      """Slices attack inputs by whether they were classified correctly.
  
      Args:
        data: Data to be used as input to the attack models.
        correctly_classified: Whether to use the indices corresponding to the
          correctly classified samples.
        return_slice_indices: if true, the returned AttackInputData will include
          indices of the train and test data samples that were used for this slice.
  
      Returns:
        AttackInputData object containing the sliced data.
      """
  
      if data.is_multilabel_data():
          raise ValueError(
              "Slicing by classification correctness not supported for "
              "multilabel data."
          )
      idx_train = _indices_by_classification(
          data.logits_or_probs_train,
          data.labels_train,
          correctly_classified,
      )
      idx_test = _indices_by_classification(
          data.logits_or_probs_test,
          data.labels_test,
          correctly_classified,
      )
      return _slice_data_by_indices(
          data, idx_train, idx_test, return_slice_indices
      )
  
file_path: privacy/tensorflow_privacy/privacy/privacy_tests/membership_inference_attack/dataset_slicing.py
imports: from collections import abc
  import copy
  import logging
  from typing import List, Optional
  import numpy
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.data_structures import AttackInputData
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.data_structures import SingleSliceSpec
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.data_structures import SlicingFeature
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.data_structures import SlicingSpec
label_desc: Use image node_id 6 for calling a global function with example usage: _slice_by_classification_correctness(data, correctly_classified, return_slice_indices) and returns: _slice_data_by_indices