code: def _test_resume_training(
      self, extra_clargs, arch="fconv_iwslt_de_en"
  ):
      flags = [
          "--fp16",
          "--log-format",
          "json",
          "--max-update",
          "10",
          "--save-interval-updates",
          "2",
          "--log-interval",
          "1",
      ] + extra_clargs
      world_size = min(torch.cuda.device_count(), 2)
      with contextlib.redirect_stdout(StringIO()):
          with tempfile.TemporaryDirectory("test_fp16") as data_dir:
              log = os.path.join(data_dir, "train.log")
              create_dummy_data(data_dir)
              preprocess_translation_data(data_dir)
              train_translation_model(
                  data_dir,
                  arch,
                  flags + ["--log-file", log],
                  world_size=world_size,
              )
              log2 = os.path.join(data_dir, "resume.log")
              restore_file = os.path.join(data_dir, "checkpoint_1_2.pt")
              train_translation_model(
                  data_dir,
                  arch,
                  flags
                  + [
                      "--log-file",
                      log2,
                      "--restore-file",
                      restore_file,
                  ],
                  world_size=world_size,
              )
  
              l1 = self.parse_logs(log)
              l2 = self.parse_logs(log2)
              assert int(l2[0]["num_updates"]) == 3, f"{l1}\n\n {l2}"
              for k in [
                  "train_loss",
                  "train_num_updates",
                  "train_ppl",
                  "train_gnorm",
              ]:
                  from_scratch, resumed = l1[-1][k], l2[-1][k]
                  assert (
                      from_scratch == resumed
                  ), f"difference at {k} {from_scratch} != {resumed}"
  
imports: import contextlib
  import json
  import logging
  import os
  import tempfile
  import unittest
  from io import StringIO
  import torch
  from fairseq import options
  from fairseq_cli import train
  from tests.utils import create_dummy_data, generate_main, preprocess_lm_data, preprocess_translation_data, train_language_model, train_translation_model
label_desc: Use image node_id 11 for calling the TestTranslationGPU obj's underlying member method code with example usage: obj._test_resume_training(extra_clargs, arch) without return types