class_docstr: Write me
      
code: def backward(self, reward, terminal):
      # Store most recent experience in memory.
      if self.step % self.memory_interval == 0:
          self.memory.append(
              self.recent_observation,
              self.recent_action,
              reward,
              terminal,
              training=self.training,
          )
  
      metrics = [np.nan for _ in self.metrics_names]
      if not self.training:
          # We're done here. No need to update the experience memory since we only use the working
          # memory to obtain the state over the most recent observations.
          return metrics
  
      if terminal:
          params = self.get_weights_flat(self.model.get_weights())
          self.memory.finalize_episode(params)
  
          if (
              self.step > self.nb_steps_warmup
              and self.episode % self.train_interval == 0
          ):
              params, reward_totals = self.memory.sample(
                  self.batch_size
              )
              best_idx = np.argsort(np.array(reward_totals))[
                  -self.num_best :
              ]
              best = np.vstack([params[i] for i in best_idx])
  
              if reward_totals[best_idx[-1]] > self.best_seen[0]:
                  self.best_seen = (
                      reward_totals[best_idx[-1]],
                      params[best_idx[-1]],
                  )
  
              metrics = [np.mean(np.array(reward_totals)[best_idx])]
              if self.processor is not None:
                  metrics += self.processor.metrics
              min_std = self.noise_ampl * np.exp(
                  -self.step * self.noise_decay_const
              )
  
              mean = np.mean(best, axis=0)
              std = np.std(best, axis=0) + min_std
              new_theta = np.hstack((mean, std))
              self.update_theta(new_theta)
          self.choose_weights()
          self.episode += 1
      return metrics
  
imports: from __future__ import division
  from collections import deque
  from copy import deepcopy
  import numpy
  import keras.backend
  from keras.models import Model
  from rl.core import Agent
  from rl.util import *
label_desc: Use image node_id 13 for calling the CEMAgent obj's underlying member method code with example usage: obj.backward(reward, terminal) and returns: metrics, metrics