class_docstr: Mixin providing support for uploading adapters to HuggingFace's Model Hub.
code: def _save_adapter_card(
      self,
      save_directory: str,
      adapter_name: str,
      adapter_repo_name: str,
      adapterhub_tag: Optional[str] = None,
      datasets_tag: Optional[str] = None,
      tags: Optional[List[str]] = None,
      language: Optional[str] = None,
      license: Optional[str] = None,
      metrics: Optional[List[str]] = None,
      **kwargs,
  ):
      all_tags = {
          "adapter-transformers"
      }  # TODO: change this tag once changed on HF side
      datasets = set()
      # Dataset/ Task info
      dataset_name = None
      if adapterhub_tag is None and datasets_tag is None:
          raise ValueError(
              "Either adapterhub_tag or datasets_tag must be specified."
          )
      if datasets_tag is not None:
          dataset_name = f"[{datasets_tag}](https://huggingface.co/datasets/{datasets_tag}/)"
          datasets.add(datasets_tag)
      if adapterhub_tag is not None:
          # adapterhub_tag overwrites datasets_tag
          dataset_name = f"[{adapterhub_tag}](https://adapterhub.ml/explore/{adapterhub_tag}/)"
          all_tags.add(f"adapterhub:{adapterhub_tag}")
  
      all_tags.add(self.config.model_type)
      if tags is not None:
          all_tags = all_tags | set(tags)
      tag_string = "\n".join([f"- {tag}" for tag in all_tags])
      if datasets:
          tag_string += "\ndatasets:\n"
          tag_string += "\n".join([f"- {tag}" for tag in datasets])
      if language:
          tag_string += f"\nlanguage:\n- {language}"
      if license:
          tag_string += f'\nlicense: "{license}"'
      if metrics:
          tag_string += "\nmetrics:\n"
          tag_string += "\n".join([f"- {metric}" for metric in metrics])
  
      if hasattr(self, "heads") and adapter_name in self.heads:
          head_type = " ".join(
              self.heads[adapter_name].config["head_type"].split("_")
          )
          head_info = f" and includes a prediction head for {head_type}"
      else:
          head_info = ""
  
      adapter_card = ADAPTER_CARD_TEMPLATE.format(
          tags=tag_string,
          model_name=self.model_name,
          dataset_name=dataset_name,
          head_info=head_info,
          adapter_repo_name=adapter_repo_name,
          architecture_training=kwargs.pop(
              "architecture_training", DEFAULT_TEXT
          ),
          results=kwargs.pop("results", DEFAULT_TEXT),
          citation=kwargs.pop("citation", DEFAULT_TEXT),
      )
  
      logger.info(
          'Saving adapter card for adapter "%s" to %s.',
          adapter_name,
          save_directory,
      )
      with open(os.path.join(save_directory, "README.md"), "w") as f:
          f.write(adapter_card.strip())
  
file_path: adapters/src/adapters/hub_mixin.py
imports: import logging
  import os
  import warnings
  from typing import List, Optional, Union
  from transformers.utils.generic import working_or_temp_dir
label_desc: Use image node_id 1 for calling the PushAdapterToHubMixin obj's underlying member method code with example usage: obj._save_adapter_card(save_directory, adapter_name, adapter_repo_name, adapterhub_tag, datasets_tag, tags, language, license, metrics) without return types