class_docstr: Basic tests on the util functions in TorchAgent.
class_docstr_tok: ["Basic","tests","on","the","util","functions","in","TorchAgent","."]
docstr: Make sure agent stores and returns observation.
docstr_tok: ["Make","sure","agent","stores","and","returns","observation","."]
code: def test_observe(self):
      """
      Make sure agent stores and returns observation.
      """
      agent = get_agent()
      # text could be none
      obs = {"text": None, "episode_done": True}
      out = agent.observe(obs.copy())
      self.assertIsNotNone(out)
      # make sure we throw an exception for having an episode done without a reset
      obs = {
          "text": "I'll be back.",
          "labels": ["I'm back."],
          "episode_done": True,
      }
      with self.assertRaises(RuntimeError):
          agent.observe(obs.copy())
      # okay, let's do it properly now
      agent.reset()
      obs = {
          "text": "I'll be back.",
          "labels": ["I'm back."],
          "episode_done": True,
      }
      out = agent.observe(obs.copy())
      self.assertIsNotNone(out)
      self.assertIsNotNone(agent.observation)
      self.assertEqual(out["text"], "I'll be back.")
      # now try with episode not done
      agent = get_agent()
      obs["episode_done"] = False
      out = agent.observe(obs.copy())
      self.assertIsNotNone(out)
      self.assertIsNotNone(agent.observation)
      self.assertEqual(out["text"], "I'll be back.")
      # should remember history
      agent.act()
      out = agent.observe(obs.copy())
      self.assertEqual(
          out["full_text"], "I'll be back.\nI'm back.\nI'll be back."
      )
  
imports: import os
  import unittest
  from parlai.core.agents import create_agent_from_shared
  from parlai.utils.testing import tempdir
  from parlai.utils.misc import Message
label_desc: Use image node_id 12 for calling the TestTorchAgent obj's underlying member method code with example usage: obj.test_observe() without return types