code: def _add_test(param_setting, methodname):
      """
      Adds a Test to TestModel according to settings
  
      Args:
          param_setting: list of tuples of (param, setting)
          methodname: name of the method that gets called
      """
  
      def test_method(self):
          opt = copy.deepcopy(self.opt)
          if param_setting:
              for param, setting in param_setting:
                  setattr(opt, param, setting)
          ArgumentParser.update_model_opts(opt)
          getattr(self, methodname)(opt)
  
      if param_setting:
          name = (
              "test_"
              + methodname
              + "_"
              + "_".join(str(param_setting).split())
          )
      else:
          name = "test_" + methodname + "_standard"
      setattr(TestModel, name, test_method)
      test_method.__name__ = name
  
imports: import copy
  import unittest
  import torch
  import pyonmttok
  from onmt.constants import DefaultTokens
  from collections import Counter
  import onmt
  import onmt.inputters
  import onmt.opts
  from onmt.model_builder import build_embeddings, build_encoder, build_decoder
  from onmt.utils.parse import ArgumentParser
label_desc: Use image node_id 1 for calling a global function with example usage: _add_test(param_setting, methodname) without return types