code: def test_save_load_custom_head(self):
      model_name = "bert-base-uncased"
      model_config = AutoConfig.from_pretrained(model_name)
      model_config.custom_heads = {"tag": CustomHead}
      model1 = AutoAdapterModel.from_pretrained(
          model_name, config=model_config
      )
      model2 = AutoAdapterModel.from_pretrained(
          model_name, config=model_config
      )
      config = {
          "num_labels": 3,
          "layers": 2,
          "activation_function": "tanh",
      }
      model1.add_custom_head(
          head_type="tag", head_name="custom_head", **config
      )
  
      with tempfile.TemporaryDirectory() as temp_dir:
          model1.save_head(temp_dir, "custom_head")
          model2.load_head(temp_dir)
  
      model1.eval()
      model2.eval()
  
      in_data = ids_tensor((1, 128), 1000)
      model1.to(torch_device)
      model2.to(torch_device)
      output1 = model1(in_data)
      output2 = model2(in_data)
      self.assertEqual(output1[0].size(), output2[0].size())
      state1 = model1.heads["custom_head"].state_dict()
      state2 = model2.heads["custom_head"].state_dict()
      for (k1, v1), (k2, v2) in zip(state1.items(), state2.items()):
          self.assertTrue(torch.equal(v1, v2))
  
file_path: adapters/tests/test_adapter_custom_head.py
imports: import tempfile
  import unittest
  import torch
  from adapters import AutoAdapterModel
  from adapters.heads import ClassificationHead, PredictionHead
  from transformers import AutoConfig
  from transformers.testing_utils import require_torch, torch_device
  from .test_adapter import ids_tensor
label_desc: Use image node_id 2 for calling the AdapterCustomHeadTest obj's underlying member method code with example usage: obj.test_save_load_custom_head() without return types