class_docstr: Tensorforce agent interface.
class_docstr_tok: ["Tensorforce","agent","interface","."]
docstr: Observes reward and whether a terminal state is reached, needs to be preceded by `act()`.
  
  See the [act-observe script](https://github.com/tensorforce/tensorforce/blob/master/examples/act_observe_interface.py)
  for an example application as part of the act-observe interface.
  
  Args:
      reward (float | iter[float]): Reward
          (<span style="color:#00C000"><b>default</b></span>: 0.0).
      terminal (bool | 0 | 1 | 2 | iter[...]): Whether a terminal state is reached, or 2 if
          the episode was aborted
          (<span style="color:#00C000"><b>default</b></span>: false).
      parallel (int, iter[int]): Parallel execution index
          (<span style="color:#00C000"><b>default</b></span>: 0).
  
  Returns:
      int: Number of performed updates.
docstr_tok: ["Observes","reward","and","whether","a","terminal","state","is","reached",",","needs","to","be","preceded","by","`","act","(",")","`",".","See","the","[","act-observe","script","]","(","https",":","\/\/github.com\/tensorforce\/tensorforce\/blob\/master\/examples\/act_observe_interface.py",")","for","an","example","application","as","part","of","the","act-observe","interface",".","Args",":","reward","(","float","|","iter","[","float","]",")",":","Reward","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0.0",")",".","terminal","(","bool","|","0","|","1","|","2","|","iter","[","...","]",")",":","Whether","a","terminal","state","is","reached",",","or","2","if","the","episode","was","aborted","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","false",")",".","parallel","(","int",",","iter","[","int","]",")",":","Parallel","execution","index","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","0",")",".","Returns",":","int",":","Number","of","performed","updates","."]
code: def observe(self, reward=0.0, terminal=False, parallel=0):
      """
      Observes reward and whether a terminal state is reached, needs to be preceded by `act()`.
  
      See the [act-observe script](https://github.com/tensorforce/tensorforce/blob/master/examples/act_observe_interface.py)
      for an example application as part of the act-observe interface.
  
      Args:
          reward (float | iter[float]): Reward
              (<span style="color:#00C000"><b>default</b></span>: 0.0).
          terminal (bool | 0 | 1 | 2 | iter[...]): Whether a terminal state is reached, or 2 if
              the episode was aborted
              (<span style="color:#00C000"><b>default</b></span>: false).
          parallel (int, iter[int]): Parallel execution index
              (<span style="color:#00C000"><b>default</b></span>: 0).
  
      Returns:
          int: Number of performed updates.
      """
      reward, terminal, parallel = super().observe(
          reward=reward, terminal=terminal, parallel=parallel
      )
  
      # Process per parallel interaction
      num_updates = 0
      for p, t, r in zip(
          parallel.tolist(), terminal.tolist(), reward.tolist()
      ):
          # Buffer inputs
          self.terminal_buffer[p].append(t)
          self.reward_buffer[p].append(r)
  
          # Continue if not terminal and buffer_observe
          if t == 0 and (
              self.config.buffer_observe == "episode"
              or len(self.terminal_buffer[p])
              < self.config.buffer_observe
          ):
              continue
  
          # Buffered terminal/reward inputs
          ts = np.asarray(
              self.terminal_buffer[p],
              dtype=self.terminal_spec.np_type(),
          )
          rs = np.asarray(
              self.reward_buffer[p], dtype=self.reward_spec.np_type()
          )
          self.terminal_buffer[p].clear()
          self.reward_buffer[p].clear()
  
          # Inputs to tensors
          terminal_tensor = self.terminal_spec.to_tensor(
              value=ts, batched=True, name="Agent.observe terminal"
          )
          reward_tensor = self.reward_spec.to_tensor(
              value=rs, batched=True, name="Agent.observe reward"
          )
          parallel_tensor = self.parallel_spec.to_tensor(
              value=p, batched=False, name="Agent.observe parallel"
          )
  
          # Model.observe()
          updated, episodes, updates = self.model.observe(
              terminal=terminal_tensor,
              reward=reward_tensor,
              parallel=parallel_tensor,
          )
          num_updates += int(updated.numpy().item())
          self.episodes = episodes.numpy().item()
          self.updates = updates.numpy().item()
  
      if self.model.saver is not None:
          self.model.save()
  
      return num_updates
  
imports: from collections import OrderedDict
  import json
  import logging
  import os
  import random
  import numpy
  import tensorflow
  from tensorforce import util, TensorforceError
  from tensorforce.agents import Recorder
  import tensorforce.agents
  from tensorforce.core import ArrayDict, TensorSpec, TensorforceConfig
label_desc: Use image node_id 14 for calling the Agent obj's underlying member method code with example usage: obj.observe(reward, terminal, parallel) and returns: num_updates