code: def run_attack_on_tf_estimator_model(
      estimator,
      in_train,
      out_train,
      input_fn_constructor,
      slicing_spec: data_structures.SlicingSpec = None,
      attack_types: Iterable[data_structures.AttackType] = (
          data_structures.AttackType.THRESHOLD_ATTACK,
      ),
  ):
      """Performs the attack in the end of training.
  
      Args:
        estimator: model to be tested
        in_train: (in_training samples, in_training labels,
          in_training_sample_weights=None)
        out_train: (out_training samples, out_training labels,
          out_training_sample_weights=None)
        input_fn_constructor: a function that receives sample, label and construct
          the input_fn for model prediction
        slicing_spec: slicing specification of the attack
        attack_types: a list of attacks, each of type AttackType
  
      Returns:
        Results of the attack
      """
  
      def unpack(data):
          sample_weights = None
          if len(data) == 2:
              inputs, labels = data
          elif len(in_train) == 3:
              inputs, labels, sample_weights = in_train
          else:
              raise ValueError(
                  "`data` should be length 2 or 3, received "
                  f"{len(data)}"
              )
          return inputs, labels, sample_weights
  
      in_train_data, in_train_labels, in_train_sample_weights = unpack(
          in_train
      )
      (
          out_train_data,
          out_train_labels,
          out_train_sample_weights,
      ) = unpack(out_train)
  
      # Define the input functions for both in and out-training samples.
      in_train_input_fn = input_fn_constructor(
          in_train_data, in_train_labels
      )
      out_train_input_fn = input_fn_constructor(
          out_train_data, out_train_labels
      )
  
      # Call the helper to run the attack.
      results = run_attack_helper(
          estimator,
          in_train_input_fn,
          out_train_input_fn,
          in_train_labels,
          out_train_labels,
          in_train_sample_weights,
          out_train_sample_weights,
          slicing_spec,
          attack_types,
      )
      logging.info("End of training attack:")
      logging.info(results)
      return results
  
file_path: privacy/tensorflow_privacy/privacy/privacy_tests/membership_inference_attack/tf_estimator_evaluation.py
imports: import os
  from typing import Iterable, Optional
  from absl import logging
  import numpy
  import tensorflow
  from tensorflow import estimator
  from tensorflow_privacy.privacy.privacy_tests import utils
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import data_structures
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import membership_inference_attack
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import utils_tensorboard
label_desc: Use image node_id 2 for calling a global function with example usage: run_attack_on_tf_estimator_model(estimator, in_train, out_train, input_fn_constructor, slicing_spec, attack_types) and returns: results, inputs,  labels,  sample_weights