class_docstr: Evaluates serialized sequence prediction models.
  
  Example: time series prediction. We can serialize a time series into
  a sequence of discrete tokens and model this sequence using an autoregressive
  sequence model, such as Transformer - see
  `trax.rl.serialization_utils.SerializedModel`. Then we can use this callback
  to evaluate long-horizon predictions of such a model.
docstr: Performs evaluation on a single batch.
docstr_tok: ["Performs","evaluation","on","a","single","batch","."]
code: def _evaluate_batch(self, batch):
      """Performs evaluation on a single batch."""
      (obs, act, _, mask) = batch
      obs_repr = serialization_utils.Serialize(self._obs_serializer)(
          obs
      )
      act_repr = serialization_utils.Serialize(self._act_serializer)(
          act
      )
  
      errors = {}
      last_context = 0
      last_state = self._init_state
      last_start_id = 0
      for context in self._context_lengths:
          self._predict_model.state = last_state
          start_id = last_start_id
  
          if context > last_context:
              context_seq = serialization_utils.Interleave()(
                  (
                      obs_repr[:, last_context:context],
                      act_repr[:, last_context:context],
                  )
              )
              consume_sequence(
                  self._predict_model, start_id, context_seq[:, :-1]
              )
              last_start_id = start_id = context_seq[:, -1:]
              last_state = self._predict_model.state
              last_context = context
  
          for timestep in range(max(self._horizon_lengths)):
              pred_repr = decoding.autoregressive_sample(
                  self._predict_model,
                  start_id=start_id,
                  eos_id=-1,
                  batch_size=self._batch_size,
                  max_length=self._obs_serializer.representation_length,
                  accelerate=False,
              )
              horizon = timestep + 1
              if horizon in self._horizon_lengths:
                  pred = self._obs_serializer.deserialize(pred_repr)
                  error = self._calculate_error(
                      pred, obs[:, context + timestep]
                  )
                  errors[context, horizon] = (
                      error * mask[:, context + timestep]
                  )
  
              start_id = pred_repr[:, -1:]
              consume_sequence(
                  self._predict_model,
                  start_id,
                  act_repr[:, context + timestep, :-1],
              )
              start_id = act_repr[:, context + timestep, -1:]
  
      return errors
  
imports: import collections
  import os
  import gin
  import numpy
  from trax import jaxboard
  from trax import layers
  from trax import shapes
  from trax.rl import serialization_utils
  from trax.supervised import decoding
label_desc: Use image node_id 7 for calling the SerializedModelEvaluation obj's underlying member method code with example usage: obj._evaluate_batch(batch) and returns: errors