docstr: Test the attack on the final models.
docstr_tok: ["Test","the","attack","on","the","final","models","."]
code: def test_run_attack_on_tf_estimator_model_with_sample_weights(self):
      """Test the attack on the final models."""
  
      def input_fn_constructor(x, y):
          return tf_compat_v1_estimator.inputs.numpy_input_fn(
              x={"x": x}, y=y, shuffle=False
          )
  
      results = (
          tf_estimator_evaluation.run_attack_on_tf_estimator_model(
              self.classifier,
              (
                  self.train_data,
                  self.train_labels,
                  self.sample_weight_train,
              ),
              (self.test_data, self.test_labels),
              input_fn_constructor,
              attack_types=[
                  data_structures.AttackType.THRESHOLD_ATTACK
              ],
          )
      )
      self.assertIsInstance(results, data_structures.AttackResults)
      (
          att_types,
          att_slices,
          att_metrics,
          att_values,
      ) = data_structures.get_flattened_attack_metrics(results)
      self.assertLen(att_types, 3)
      self.assertLen(att_slices, 3)
      self.assertLen(att_metrics, 3)
      self.assertLen(att_values, 3)
  
file_path: privacy/tensorflow_privacy/privacy/privacy_tests/membership_inference_attack/tf_estimator_evaluation_test.py
imports: from absl.testing import absltest
  import numpy
  import tensorflow
  from tensorflow import estimator
  from tensorflow.compat.v1 import estimator
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import data_structures
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import tf_estimator_evaluation
label_desc: Use image node_id 6 for calling the UtilsTest obj's underlying member method code with example usage: obj.test_run_attack_on_tf_estimator_model_with_sample_weights() and returns: tf_compat_v1_estimator