class_docstr: Test of BART model.
docstr: FT BART on a "reverse" task (the opposite of what it was trained to do)
code: def test_bart_ft(self):
      """
      FT BART on a "reverse" task (the opposite of what it was trained to do)
      """
      with tempdir() as tmpdir:
          # test finetuning
          mf = os.path.join(tmpdir, "model")
          valid, test = testing_utils.train_model(
              dict(
                  task="integration_tests:reverse",
                  model="bart",
                  dict_file="zoo:bart/bart_large/model.dict",
                  optimizer="sgd",
                  learningrate=1,
                  batchsize=2,
                  num_epochs=1,
                  short_final_eval=True,
                  validation_max_exs=12,
                  model_file=mf,
                  model_parallel=True,
                  fp16=True,
              )
          )
          self.assertAlmostEqual(valid["ppl"].value(), 1.0, places=1)
          self.assertAlmostEqual(test["ppl"].value(), 1.0, places=1)
  
          # test generation
          opt = ParlaiParser(True, True).parse_args(
              ["--model-file", mf]
          )
          bart = create_agent(opt)
          text = "1 2 3 4"
          obs = {"text": text, "episode_done": True}
          bart.observe(obs)
          act = bart.act()
          self.assertEqual(act["text"], text[::-1])
  
file_path: ParlAI/tests/nightly/gpu/test_bart.py
imports: import os
  import unittest
  from parlai.core.agents import create_agent
  from parlai.core.params import ParlaiParser
  import parlai.utils.testing
  from parlai.utils.testing import tempdir
label_desc: Use image node_id 4 for calling the TestBartModel obj's underlying member method code with example usage: obj.test_bart_ft() without return types