class_docstr: Autoencoder-augmented Transformer.
class_docstr_tok: ["Autoencoder-augmented","Transformer","."]
docstr: Constructs `tf.estimator.EstimatorSpec` for EVAL (evaluation) mode.
docstr_tok: ["Constructs","`","tf.estimator.EstimatorSpec","`","for","EVAL","(","evaluation",")","mode","."]
code: def estimator_spec_eval(
      self, features, logits, labels, loss, losses_dict
  ):
      """Constructs `tf.estimator.EstimatorSpec` for EVAL (evaluation) mode."""
      estimator_spec = super(TransformerAE, self).estimator_spec_eval(
          features, logits, labels, loss, losses_dict
      )
      if common_layers.is_xla_compiled():
          # For TPUs (and XLA more broadly?), do not add summary hooks that depend
          # on losses; they are not supported.
          return estimator_spec
  
      summary_op = tf.get_collection(
          tf.GraphKeys.SUMMARIES, scope="losses"
      )
      summary_op.extend(
          tf.get_collection(tf.GraphKeys.SUMMARIES, scope="loss")
      )
      summary_op.append(tf.summary.scalar("loss", loss))
      summary_saver_hook = tf.train.SummarySaverHook(
          save_steps=100,
          summary_op=summary_op,
          output_dir=os.path.join(self.hparams.model_dir, "eval"),
      )
  
      hooks = list(estimator_spec.evaluation_hooks)
      hooks.append(summary_saver_hook)
      return estimator_spec._replace(evaluation_hooks=hooks)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import math
  import os
  from six.moves import range
  from tensor2tensor.layers import common_attention
  from tensor2tensor.layers import common_image_attention
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import discretization
  from tensor2tensor.layers import latent_layers
  from tensor2tensor.layers import modalities
  from tensor2tensor.models import transformer
  from tensor2tensor.utils import beam_search
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import expert_utils
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 5 for calling the TransformerAE obj's underlying member method code with example usage: obj.estimator_spec_eval(features, logits, labels, loss, losses_dict) and returns: estimator_spec, estimator_spec