code: def test_finetune(self, model):
      args_d: dict = CHEAP_ARGS.copy()
      task = (
          "translation"
          if model in [MBART_TINY, MARIAN_TINY, FSMT_TINY]
          else "summarization"
      )
      args_d["label_smoothing"] = 0.1 if task == "translation" else 0
  
      tmp_dir = make_test_data_dir(
          tmp_dir=self.get_auto_remove_tmp_dir()
      )
      output_dir = self.get_auto_remove_tmp_dir()
      args_d.update(
          data_dir=tmp_dir,
          model_name_or_path=model,
          tokenizer_name=None,
          train_batch_size=2,
          eval_batch_size=2,
          output_dir=output_dir,
          do_predict=True,
          task=task,
          src_lang="en_XX",
          tgt_lang="ro_RO",
          freeze_encoder=True,
          freeze_embeds=True,
      )
      assert "n_train" in args_d
      args = argparse.Namespace(**args_d)
      module = main(args)
  
      input_embeds = module.model.get_input_embeddings()
      assert not input_embeds.weight.requires_grad
      if model == T5_TINY:
          lm_head = module.model.lm_head
          assert not lm_head.weight.requires_grad
          assert (lm_head.weight == input_embeds.weight).all().item()
      elif model == FSMT_TINY:
          fsmt = module.model.model
          embed_pos = fsmt.decoder.embed_positions
          assert not embed_pos.weight.requires_grad
          assert not fsmt.decoder.embed_tokens.weight.requires_grad
          # check that embeds are not the same
          assert fsmt.decoder.embed_tokens != fsmt.encoder.embed_tokens
      else:
          bart = module.model.model
          embed_pos = bart.decoder.embed_positions
          assert not embed_pos.weight.requires_grad
          assert not bart.shared.weight.requires_grad
          # check that embeds are the same
          assert bart.decoder.embed_tokens == bart.encoder.embed_tokens
          assert bart.decoder.embed_tokens == bart.shared
  
      example_batch = load_json(module.output_dir / "text_batch.json")
      assert isinstance(example_batch, dict)
      assert len(example_batch) >= 4
  
imports: import argparse
  import logging
  import os
  import sys
  import tempfile
  from pathlib import Path
  import pytest
  import pytorch_lightning
  import torch
  from torch import nn
  import lightning_base
  from convert_pl_checkpoint_to_hf import convert_pl_to_hf
  from distillation import distill_main
  from finetune import SummarizationModule, main
  from huggingface_hub import list_models
  from parameterized import parameterized
  from run_eval import generate_summaries_or_translations
  from transformers import AutoConfig, AutoModelForSeq2SeqLM
  from transformers.testing_utils import CaptureStderr, CaptureStdout, TestCasePlus, require_torch_gpu, slow
  from utils import label_smoothed_nll_loss, lmap, load_json
label_desc: Use image node_id 1 for calling the TestTheRest obj's underlying member method code with example usage: obj.test_finetune(model) without return types