class_docstr: Basic tests on the util functions in TorchAgent.
class_docstr_tok: ["Basic","tests","on","the","util","functions","in","TorchAgent","."]
docstr: Make sure predictions are correctly aligned when available.
docstr_tok: ["Make","sure","predictions","are","correctly","aligned","when","available","."]
code: def test_match_batch(self):
      """
      Make sure predictions are correctly aligned when available.
      """
      agent = get_agent()
  
      # first try empty outputs
      reply = agent.match_batch([{}, {}, {}], [0, 1, 2], Output())
      self.assertEqual([{}, {}, {}], reply)
      reply = agent.match_batch([{}, {}, {}], [0, 1, 2], None)
      self.assertEqual([{}, {}, {}], reply)
  
      # try text in order
      reply = agent.match_batch(
          [{}, {}, {}], [0, 1, 2], Output(["E.T.", "Phone", "Home"])
      )
      self.assertEqual(
          [{"text": "E.T."}, {"text": "Phone"}, {"text": "Home"}], reply
      )
  
      # try text out of order
      reply = agent.match_batch(
          [{}, {}, {}], [2, 0, 1], Output(["Home", "E.T.", "Phone"])
      )
      self.assertEqual(
          [{"text": "E.T."}, {"text": "Phone"}, {"text": "Home"}], reply
      )
  
      # try text_candidates in order
      reply = agent.match_batch(
          [{}, {}],
          [0, 1],
          Output(
              None,
              [
                  ["More human than human.", "Less human than human"],
                  ["Just walk into Mordor", "Just QWOP into Mordor."],
              ],
          ),
      )
      self.assertEqual(
          reply[0]["text_candidates"],
          ["More human than human.", "Less human than human"],
      )
      self.assertEqual(
          reply[1]["text_candidates"],
          ["Just walk into Mordor", "Just QWOP into Mordor."],
      )
      # try text_candidates out of order
      reply = agent.match_batch(
          [{}, {}],
          [1, 0],
          Output(
              None,
              [
                  ["More human than human.", "Less human than human"],
                  ["Just walk into Mordor", "Just QWOP into Mordor."],
              ],
          ),
      )
      self.assertEqual(
          reply[0]["text_candidates"],
          ["Just walk into Mordor", "Just QWOP into Mordor."],
      )
      self.assertEqual(
          reply[1]["text_candidates"],
          ["More human than human.", "Less human than human"],
      )
  
      # try both text and text_candidates in order
      reply = agent.match_batch(
          [{}, {}],
          [0, 1],
          Output(
              ["You shall be avenged...", "Man creates dinosaurs..."],
              [
                  ["By Grabthar’s hammer.", "By the suns of Worvan."],
                  ["Dinosaurs eat man.", "Woman inherits the earth."],
              ],
          ),
      )
      self.assertEqual(reply[0]["text"], "You shall be avenged...")
      self.assertEqual(
          reply[0]["text_candidates"],
          ["By Grabthar’s hammer.", "By the suns of Worvan."],
      )
      self.assertEqual(reply[1]["text"], "Man creates dinosaurs...")
      self.assertEqual(
          reply[1]["text_candidates"],
          ["Dinosaurs eat man.", "Woman inherits the earth."],
      )
  
      # try both text and text_candidates out of order
      reply = agent.match_batch(
          [{}, {}],
          [1, 0],
          Output(
              ["You shall be avenged...", "Man creates dinosaurs..."],
              [
                  ["By Grabthar’s hammer.", "By the suns of Worvan."],
                  ["Dinosaurs eat man.", "Woman inherits the earth."],
              ],
          ),
      )
      self.assertEqual(reply[0]["text"], "Man creates dinosaurs...")
      self.assertEqual(
          reply[0]["text_candidates"],
          ["Dinosaurs eat man.", "Woman inherits the earth."],
      )
      self.assertEqual(reply[1]["text"], "You shall be avenged...")
      self.assertEqual(
          reply[1]["text_candidates"],
          ["By Grabthar’s hammer.", "By the suns of Worvan."],
      )
  
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 7 for calling the TestTorchAgent obj's underlying member method code with example usage: obj.test_match_batch() without return types