class_docstr: Provides base test running methods for testing an adapter method implementation.
class_docstr_tok: ["Provides","base","test","running","methods","for","testing","an","adapter","method","implementation","."]
code: def run_train_test(self, adapter_config, filter_keys):
      if not self.do_run_train_tests:
          self.skipTest(
              "Skipping training tests. Set `do_run_train_tests=True` to run them."
          )
      if self.config_class not in ADAPTER_MODEL_MAPPING:
          self.skipTest("Does not support flex heads.")
      model = AutoAdapterModel.from_config(self.config())
  
      # add two adapters: one will be trained and the other should be frozen
      model.add_adapter("mrpc", config=adapter_config)
      model.add_adapter("dummy", config=adapter_config)
      self.add_head(model, "mrpc")
  
      self.assert_adapter_available(model, "mrpc")
      self.assert_adapter_available(model, "dummy")
  
      # train the mrpc adapter -> should be activated & unfreezed
      model.train_adapter("mrpc")
      self.assertEqual(set(["mrpc"]), model.active_adapters.flatten())
  
      # all weights of the adapter should be activated
      has_weights = False
      filter_keys_trained = [k.format(name="mrpc") for k in filter_keys]
      for k, v in self.filter_parameters(
          model, filter_keys_trained
      ).items():
          has_weights = True
          self.assertTrue(v.requires_grad, k)
      self.assertTrue(has_weights)
      # all weights of the adapter not used for training should be frozen
      filter_keys_untrained = [
          k.format(name="dummy") for k in filter_keys
      ]
      for k, v in self.filter_parameters(
          model, filter_keys_untrained
      ).items():
          self.assertFalse(v.requires_grad, k)
  
      state_dict_pre = copy.deepcopy(model.state_dict())
  
      self.trainings_run(model)
  
      # check that the adapters have changed, but the base model has not
      adapters_with_change, base_with_change = False, False
      # check whether the key corresponds to a tied embedding
  
      def has_tied_embeddings(k):
          tied_embeddings = (
              hasattr(model.config, "tie_word_embeddings")
              and model.config.tie_word_embeddings
          )
          is_tied_layer = (
              isinstance(model.heads["mrpc"], CausalLMHead)
              and "heads.{}.{}.weight".format(
                  "mrpc", len(model.heads["mrpc"]._modules) - 1
              )
              in k
          )
          return tied_embeddings and is_tied_layer
  
      for (k1, v1), (k2, v2) in zip(
          state_dict_pre.items(), model.state_dict().items()
      ):
          if "mrpc" in k1 and not has_tied_embeddings(k1):
              adapters_with_change |= not torch.equal(v1, v2)
          else:
              base_with_change |= not torch.equal(v1, v2)
      self.assertTrue(adapters_with_change)
      self.assertFalse(base_with_change)
  
imports: import copy
  import os
  import tempfile
  import torch
  import adapters
  from adapters import ADAPTER_MODEL_MAPPING, AdapterSetup, AdapterTrainer, AutoAdapterModel
  from adapters.heads import CausalLMHead
  from adapters.utils import WEIGHTS_NAME
  from adapters.wrappers import load_model
  from transformers import TrainingArguments
  from transformers.testing_utils import require_torch, torch_device
label_desc: Use image node_id 11 for calling the AdapterMethodBaseTestMixin obj's underlying member method code with example usage: obj.run_train_test(adapter_config, filter_keys) and returns: unknown