parameters: (self, features, mode, state)
return_statement: return per_observation_loss, state, outputs
docstring: Computes predictions, losses, and intermediate model states.
  
      Args:
        features: A dictionary with times, values, and (optionally) exogenous
            regressors. See `define_loss`.
        mode: The tf.estimator.ModeKeys mode to use (TRAIN, EVAL, INFER).
        state: Model-dependent state, each with size [batch size x ...]. The
            number and type will typically be fixed by the model (for example a
            mean and variance).
      Returns:
        A tuple of (loss, filtered_states, predictions)
          loss: Average loss values across the batch.
          filtered_states: For each Tensor in `state` with shape [batch size x
              ...], `filtered_states` has a Tensor with shape [batch size x window
              size x ...] with filtered state for each part of the batch and
              window.
          predictions: A dictionary with model-dependent one-step-ahead (or
              at-least-one-step-ahead with missing values) predictions, with keys
              indicating the type of prediction and values having shape [batch
              size x window size x ...]. For example state space models provide
              "mean", "covariance", and "log_likelihood".
docstring_summary: Computes predictions, losses, and intermediate model states.
docstring_tokens: Computes predictions losses and intermediate model states .
function: def per_step_batch_loss(self, features, mode, state):
      """Computes predictions, losses, and intermediate model states.
  
      Args:
        features: A dictionary with times, values, and (optionally) exogenous
            regressors. See `define_loss`.
        mode: The tf.estimator.ModeKeys mode to use (TRAIN, EVAL, INFER).
        state: Model-dependent state, each with size [batch size x ...]. The
            number and type will typically be fixed by the model (for example a
            mean and variance).
      Returns:
        A tuple of (loss, filtered_states, predictions)
          loss: Average loss values across the batch.
          filtered_states: For each Tensor in `state` with shape [batch size x
              ...], `filtered_states` has a Tensor with shape [batch size x window
              size x ...] with filtered state for each part of the batch and
              window.
          predictions: A dictionary with model-dependent one-step-ahead (or
              at-least-one-step-ahead with missing values) predictions, with keys
              indicating the type of prediction and values having shape [batch
              size x window size x ...]. For example state space models provide
              "mean", "covariance", and "log_likelihood".
  
      """
      self._check_graph_initialized()
      times = math_ops.cast(features[TrainEvalFeatures.TIMES], dtype=dtypes.int64)
      values = math_ops.cast(features[TrainEvalFeatures.VALUES], dtype=self.dtype)
      exogenous_regressors = self._process_exogenous_features(
          times=times,
          features={key: value for key, value in features.items()
                    if key not in [TrainEvalFeatures.TIMES,
                                   TrainEvalFeatures.VALUES]})
      def _batch_loss_filtering_step(step_number, current_times, state):
        """Make a prediction and update it based on data."""
        current_values = values[:, step_number, :]
        state = self._apply_exogenous_update(
            step_number=step_number, current_times=current_times, state=state,
            raw_features=features,
            embedded_exogenous_regressors=exogenous_regressors)
        predicted_state, predictions = self._prediction_step(
            current_times=current_times,
            state=state)
        filtered_state, outputs = self._filtering_step(
            current_times=current_times,
            current_values=current_values,
            state=predicted_state,
            predictions=predictions)
        return filtered_state, outputs
      state, outputs = self._state_update_loop(
          times=times, state=state, state_update_fn=_batch_loss_filtering_step,
          outputs=["loss"] + self._train_output_names)
      outputs["loss"].set_shape(times.get_shape())
      loss_sum = math_ops.reduce_sum(outputs["loss"])
      per_observation_loss = (loss_sum / math_ops.cast(
          math_ops.reduce_prod(array_ops.shape(times)), dtype=self.dtype))
      per_observation_loss += self._loss_additions(times, values, mode)
      # Since we have window-level additions to the loss, its per-step value is
      # misleading, so we avoid returning it.
      del outputs["loss"]
      return per_observation_loss, state, outputs
function_tokens: def per_step_batch_loss ( self , features , mode , state ) : self . _check_graph_initialized ( ) times = math_ops . cast ( features [ TrainEvalFeatures . TIMES ] , dtype = dtypes . int64 ) values = math_ops . cast ( features [ TrainEvalFeatures . VALUES ] , dtype = self . dtype ) exogenous_regressors = self . _process_exogenous_features ( times = times , features = { key : value for key , value in features . items ( ) if key not in [ TrainEvalFeatures . TIMES , TrainEvalFeatures . VALUES ] } ) def _batch_loss_filtering_step ( step_number , current_times , state ) : """Make a prediction and update it based on data.""" current_values = values [ : , step_number , : ] state = self . _apply_exogenous_update ( step_number = step_number , current_times = current_times , state = state , raw_features = features , embedded_exogenous_regressors = exogenous_regressors ) predicted_state , predictions = self . _prediction_step ( current_times = current_times , state = state ) filtered_state , outputs = self . _filtering_step ( current_times = current_times , current_values = current_values , state = predicted_state , predictions = predictions ) return filtered_state , outputs state , outputs = self . _state_update_loop ( times = times , state = state , state_update_fn = _batch_loss_filtering_step , outputs = [ "loss" ] + self . _train_output_names ) outputs [ "loss" ] . set_shape ( times . get_shape ( ) ) loss_sum = math_ops . reduce_sum ( outputs [ "loss" ] ) per_observation_loss = ( loss_sum / math_ops . cast ( math_ops . reduce_prod ( array_ops . shape ( times ) ) , dtype = self . dtype ) ) per_observation_loss += self . _loss_additions ( times , values , mode ) # Since we have window-level additions to the loss, its per-step value is # misleading, so we avoid returning it. del outputs [ "loss" ] return per_observation_loss , state , outputs