class_docstr: Callback to perform membership inference attack on epoch end.
class_docstr_tok: ["Callback","to","perform","membership","inference","attack","on","epoch","end","."]
code: def on_epoch_end(self, epoch, logs=None):
      results = run_attack_on_keras_model(
          self.model,
          (self._in_train_data, self._in_train_labels),
          (self._out_train_data, self._out_train_labels),
          self._slicing_spec,
          self._attack_types,
          self._is_logit,
          self._batch_size,
      )
      logging.info(results)
  
      (
          att_types,
          att_slices,
          att_metrics,
          att_values,
      ) = get_flattened_attack_metrics(results)
      print("Attack result:")
      print(
          "\n".join(
              [
                  "  %s: %.4f" % (", ".join([s, t, m]), v)
                  for t, s, m, v in zip(
                      att_types, att_slices, att_metrics, att_values
                  )
              ]
          )
      )
  
      # Write to tensorboard if tensorboard_dir is specified
      if self._writers is not None:
          write_results_to_tensorboard(
              results,
              self._writers,
              epoch,
              self._tensorboard_merge_classifiers,
          )
  
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 the MembershipInferenceCallback obj's underlying member method code with example usage: obj.on_epoch_end(epoch, logs) without return types