code: def run_attack_on_keras_model(
      model,
      in_train,
      out_train,
      slicing_spec: SlicingSpec = None,
      attack_types: Iterable[AttackType] = (
          AttackType.THRESHOLD_ATTACK,
      ),
      is_logit: bool = False,
      batch_size: int = 32,
  ):
      """Performs the attack on a trained model.
  
      Args:
        model: model to be tested
        in_train: a (in_training samples, in_training labels) tuple
        out_train: a (out_training samples, out_training labels) tuple
        slicing_spec: slicing specification of the attack
        attack_types: a list of attacks, each of type AttackType
        is_logit: whether the result of model.predict is logit or probability
        batch_size: the batch size for model.predict
  
      Returns:
        Results of the attack
      """
      in_train_data, in_train_labels = in_train
      out_train_data, out_train_labels = out_train
  
      # Compute predictions and losses
      in_train_pred, in_train_loss = calculate_losses(
          model, in_train_data, in_train_labels, is_logit, batch_size
      )
      out_train_pred, out_train_loss = calculate_losses(
          model, out_train_data, out_train_labels, is_logit, batch_size
      )
      attack_input = AttackInputData(
          logits_train=in_train_pred,
          logits_test=out_train_pred,
          labels_train=in_train_labels,
          labels_test=out_train_labels,
          loss_train=in_train_loss,
          loss_test=out_train_loss,
      )
      results = mia.run_attacks(
          attack_input,
          slicing_spec=slicing_spec,
          attack_types=attack_types,
      )
      return results
  
file_path: privacy/tensorflow_privacy/privacy/privacy_tests/membership_inference_attack/keras_evaluation.py
imports: import os
  from typing import Iterable
  from absl import logging
  import tensorflow
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import membership_inference_attack
  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 AttackType
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.data_structures import get_flattened_attack_metrics
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.data_structures import SlicingSpec
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.utils_tensorboard import write_results_to_tensorboard_tf2
  from tensorflow_privacy.privacy.privacy_tests.utils import log_loss
label_desc: Use image node_id 2 for calling a global function with example usage: run_attack_on_keras_model(model, in_train, out_train, slicing_spec, attack_types, is_logit, batch_size) and returns: results