code: def test_slice_by_class(self):
      class_index = 1
      class_slice = SingleSliceSpec(SlicingFeature.CLASS, class_index)
      output = get_slice(self.input_data, class_slice)
  
      # Check logits.
      self.assertLen(output.logits_train, 2)
      self.assertLen(output.logits_test, 1)
      self.assertTrue((output.logits_train[1] == [4, 5, 0]).all())
  
      # Check probs.
      self.assertLen(output.probs_train, 2)
      self.assertLen(output.probs_test, 1)
      self.assertTrue((output.probs_train[1] == [0.4, 0.6, 0]).all())
  
      # Check labels.
      self.assertLen(output.labels_train, 2)
      self.assertLen(output.labels_test, 1)
      self.assertTrue((output.labels_train == class_index).all())
      self.assertTrue((output.labels_test == class_index).all())
  
      # Check losses
      self.assertLen(output.loss_train, 2)
      self.assertLen(output.loss_test, 1)
      self.assertTrue((output.loss_train == [2, 4]).all())
      self.assertTrue((output.loss_test == [0.5]).all())
  
      # Check entropy
      self.assertLen(output.entropy_train, 2)
      self.assertLen(output.entropy_test, 1)
      self.assertTrue((output.entropy_train == [0.4, 0.6]).all())
      self.assertTrue((output.entropy_test == [15]).all())
  
      # Check sample weights
      self.assertLen(output.sample_weight_train, 2)
      np.testing.assert_array_equal(
          output.sample_weight_train, [1.0, 0.5]
      )
      self.assertLen(output.sample_weight_test, 1)
      np.testing.assert_array_equal(output.sample_weight_test, [0.5])
  
imports: import logging
  from absl.testing import absltest
  from absl.testing import parameterized
  from absl.testing.absltest import mock
  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
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.dataset_slicing import get_single_slice_specs
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.dataset_slicing import get_slice
label_desc: Use image node_id 3 for calling the GetSliceTest obj's underlying member method code with example usage: obj.test_slice_by_class() without return types