code: def test_train(self):
      pre_train_config = self._get_pre_train_config(
          head_num_classes=100
      )
      pre_train_task = build_task(pre_train_config)
      trainer = LocalTrainer()
      trainer.train(pre_train_task)
      checkpoint = get_checkpoint_dict(pre_train_task, {})
  
      for reset_heads, heads_num_classes in [(False, 100), (True, 20)]:
          for freeze_trunk in [True, False]:
              fine_tuning_config = self._get_fine_tuning_config(
                  head_num_classes=heads_num_classes
              )
              fine_tuning_task = build_task(fine_tuning_config)
              fine_tuning_task = (
                  fine_tuning_task._set_pretrained_checkpoint_dict(
                      copy.deepcopy(checkpoint)
                  )
                  .set_reset_heads(reset_heads)
                  .set_freeze_trunk(freeze_trunk)
              )
              # run in test mode to compare the model state
              fine_tuning_task.set_test_only(True)
              trainer.train(fine_tuning_task)
              self._compare_model_state(
                  pre_train_task.model.get_classy_state(),
                  fine_tuning_task.model.get_classy_state(),
                  check_heads=not reset_heads,
              )
              # run in train mode to check accuracy
              fine_tuning_task.set_test_only(False)
              trainer.train(fine_tuning_task)
              if freeze_trunk:
                  # if trunk is frozen the states should be the same
                  self._compare_model_state(
                      pre_train_task.model.get_classy_state(),
                      fine_tuning_task.model.get_classy_state(),
                      check_heads=False,
                  )
              else:
                  # trunk isn't frozen, the states should be different
                  with self.assertRaises(Exception):
                      self._compare_model_state(
                          pre_train_task.model.get_classy_state(),
                          fine_tuning_task.model.get_classy_state(),
                          check_heads=False,
                      )
  
              accuracy = fine_tuning_task.meters[0].value["top_1"]
              self.assertAlmostEqual(accuracy, 1.0)
  
imports: import copy
  import unittest
  from typing import Any, Dict
  from unittest import mock
  import torch
  import torch.nn
  from classy_vision.generic.util import get_checkpoint_dict
  from classy_vision.losses import ClassyLoss, register_loss
  from classy_vision.tasks import build_task, FineTuningTask
  from classy_vision.trainer import LocalTrainer
  from test.generic.config_utils import get_fast_test_task_config
  from test.generic.utils import compare_model_state
  from torch.nn.modules.loss import CrossEntropyLoss
label_desc: Use image node_id 7 for calling the TestFineTuningTask obj's underlying member method code with example usage: obj.test_train() without return types