code: def _get_batch_loss_metrics(
      batch_logits: np.ndarray, batch_labels: np.ndarray
  ) -> Tuple[float, int]:
      """Returns the loss, number of sequences for a batch.
  
      Args:
        batch_logits: Logits returned by a seq2seq model, dim = (num_sequences,
          num_tokens, vocab_size).
        batch_labels: Target labels for the seq2seq model, dim = (num_sequences,
          num_tokens, 1).
      """
      batch_loss = 0.0
      batch_length = len(batch_logits)
      for sequence_logits, sequence_labels in zip(
          batch_logits, batch_labels
      ):
          sequence_loss = tf.losses.sparse_categorical_crossentropy(
              tf.keras.backend.constant(sequence_labels),
              tf.keras.backend.constant(sequence_logits),
              from_logits=True,
          )
          if tf.executing_eagerly():
              batch_loss += sequence_loss.numpy().sum()
          else:
              batch_loss += tf.reduce_sum(sequence_loss)
  
      if not tf.executing_eagerly():
          session = tf.compat.v1.Session()
          batch_loss = batch_loss.eval(
              session
          )  # pytype: disable=attribute-error
      return batch_loss / batch_length, batch_length
  
imports: import dataclasses
  from typing import Iterator, List, Optional, Tuple
  import numpy
  from scipy import stats
  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 AttackResults
  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 PrivacyReportMetadata
label_desc: Use image node_id 5 for calling a global function with example usage: _get_batch_loss_metrics(batch_logits, batch_labels) and returns: unknown,  batch_length