class_docstr: Basic tests on the util functions in TorchAgent.
class_docstr_tok: ["Basic","tests","on","the","util","functions","in","TorchAgent","."]
docstr: Make sure we are truncating when needed.
docstr_tok: ["Make","sure","we","are","truncating","when","needed","."]
code: def test__check_truncate(self):
      """
      Make sure we are truncating when needed.
      """
      agent = get_agent()
      inp = torch.LongTensor([1, 2, 3])
      self.assertEqual(
          agent._check_truncate(inp, None).tolist(), [1, 2, 3]
      )
      self.assertEqual(
          agent._check_truncate(inp, 4).tolist(), [1, 2, 3]
      )
      self.assertEqual(
          agent._check_truncate(inp, 3).tolist(), [1, 2, 3]
      )
      self.assertEqual(agent._check_truncate(inp, 2).tolist(), [1, 2])
      self.assertEqual(agent._check_truncate(inp, 1).tolist(), [1])
      self.assertEqual(agent._check_truncate(inp, 0).tolist(), [])
  
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 4 for calling the TestTorchAgent obj's underlying member method code with example usage: obj.test__check_truncate() without return types