code: def test_save_to_hub(
      monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
  ) -> None:
      def mock_create_repo(self, repo_id, **kwargs):
          return RepoUrl(f"https://huggingface.co/{repo_id}")
  
      mock_upload_folder_kwargs = {}
  
      def mock_upload_folder(self, **kwargs):
          nonlocal mock_upload_folder_kwargs
          mock_upload_folder_kwargs = kwargs
  
      def mock_list_repo_refs(self, repo_id=None, **kwargs):
          try:
              git_ref_info = GitRefInfo(
                  name="main",
                  ref="refs/heads/main",
                  target_commit="123456",
              )
          except TypeError:
              git_ref_info = GitRefInfo(
                  dict(
                      name="main",
                      ref="refs/heads/main",
                      targetCommit="123456",
                  )
              )
          # workaround for https://github.com/huggingface/huggingface_hub/issues/1956
          git_ref_kwargs = {
              "branches": [git_ref_info],
              "converts": [],
              "tags": [],
              "pull_requests": None,
          }
          try:
              return GitRefs(**git_ref_kwargs)
          except TypeError:
              git_ref_kwargs.pop("pull_requests")
              return GitRefs(**git_ref_kwargs)
  
      monkeypatch.setattr(HfApi, "create_repo", mock_create_repo)
      monkeypatch.setattr(HfApi, "upload_folder", mock_upload_folder)
      monkeypatch.setattr(HfApi, "list_repo_refs", mock_list_repo_refs)
  
      model = SentenceTransformer(
          "sentence-transformers-testing/stsb-bert-tiny-safetensors"
      )
      url = model.save_to_hub(
          "sentence-transformers-testing/stsb-bert-tiny-safetensors"
      )
      assert (
          mock_upload_folder_kwargs["repo_id"]
          == "sentence-transformers-testing/stsb-bert-tiny-safetensors"
      )
      assert (
          url
          == "https://huggingface.co/sentence-transformers-testing/stsb-bert-tiny-safetensors/commit/123456"
      )
      mock_upload_folder_kwargs.clear()
  
      with pytest.raises(
          ValueError,
          match="Providing an `organization` to `save_to_hub` is deprecated, please only use `repo_id`.",
      ):
          model.save_to_hub(
              "sentence-transformers-testing/stsb-bert-tiny-safetensors",
              organization="unrelated",
          )
  
      caplog.clear()
      with caplog.at_level(logging.WARNING):
          url = model.save_to_hub(
              "sentence-transformers-testing/stsb-bert-tiny-safetensors",
              organization="sentence-transformers-testing",
          )
          assert (
              mock_upload_folder_kwargs["repo_id"]
              == "sentence-transformers-testing/stsb-bert-tiny-safetensors"
          )
          assert (
              url
              == "https://huggingface.co/sentence-transformers-testing/stsb-bert-tiny-safetensors/commit/123456"
          )
          assert len(caplog.record_tuples) == 1
          assert (
              caplog.record_tuples[0][2]
              == 'Providing an `organization` to `save_to_hub` is deprecated, please only use `repo_id="sentence-transformers-testing/stsb-bert-tiny-safetensors"` instead.'
          )
      mock_upload_folder_kwargs.clear()
  
      caplog.clear()
      with caplog.at_level(logging.WARNING):
          url = model.save_to_hub(
              "stsb-bert-tiny-safetensors",
              organization="sentence-transformers-testing",
          )
          assert (
              mock_upload_folder_kwargs["repo_id"]
              == "sentence-transformers-testing/stsb-bert-tiny-safetensors"
          )
          assert (
              url
              == "https://huggingface.co/sentence-transformers-testing/stsb-bert-tiny-safetensors/commit/123456"
          )
          assert len(caplog.record_tuples) == 1
          assert (
              caplog.record_tuples[0][2]
              == 'Providing an `organization` to `save_to_hub` is deprecated, please use `repo_id="sentence-transformers-testing/stsb-bert-tiny-safetensors"` instead.'
          )
      mock_upload_folder_kwargs.clear()
  
      url = model.save_to_hub(
          "sentence-transformers-testing/stsb-bert-tiny-safetensors",
          local_model_path="my_fake_local_model_path",
      )
      assert (
          mock_upload_folder_kwargs["repo_id"]
          == "sentence-transformers-testing/stsb-bert-tiny-safetensors"
      )
      assert (
          mock_upload_folder_kwargs["folder_path"]
          == "my_fake_local_model_path"
      )
      assert (
          url
          == "https://huggingface.co/sentence-transformers-testing/stsb-bert-tiny-safetensors/commit/123456"
      )
      mock_upload_folder_kwargs.clear()
  
      # Incorrect usage: Using deprecated "repo_name" positional argument
      caplog.clear()
      with caplog.at_level(logging.WARNING):
          url = model.save_to_hub(
              repo_name="sentence-transformers-testing/stsb-bert-tiny-safetensors"
          )
          assert (
              mock_upload_folder_kwargs["repo_id"]
              == "sentence-transformers-testing/stsb-bert-tiny-safetensors"
          )
          assert (
              url
              == "https://huggingface.co/sentence-transformers-testing/stsb-bert-tiny-safetensors/commit/123456"
          )
          assert len(caplog.record_tuples) == 1
          assert (
              caplog.record_tuples[0][2]
              == "Providing a `repo_name` keyword argument to `save_to_hub` is deprecated, please use `repo_id` instead."
          )
      mock_upload_folder_kwargs.clear()
  
      # Incorrect usage: Use positional arguments from before "token" was introduced
      caplog.clear()
      with caplog.at_level(logging.WARNING):
          url = model.save_to_hub(
              "stsb-bert-tiny-safetensors",  # repo_name
              "sentence-transformers-testing",  # organization
              True,  # private
              "Adding new awesome Model!",  # commit message
              exist_ok=True,
          )
          assert (
              mock_upload_folder_kwargs["repo_id"]
              == "sentence-transformers-testing/stsb-bert-tiny-safetensors"
          )
          assert (
              mock_upload_folder_kwargs["commit_message"]
              == "Adding new awesome Model!"
          )
          assert (
              url
              == "https://huggingface.co/sentence-transformers-testing/stsb-bert-tiny-safetensors/commit/123456"
          )
          assert len(caplog.record_tuples) == 1
          assert (
              caplog.record_tuples[0][2]
              == 'Providing an `organization` to `save_to_hub` is deprecated, please use `repo_id="sentence-transformers-testing/stsb-bert-tiny-safetensors"` instead.'
          )
  
file_path: sentence-transformers/tests/test_sentence_transformer.py
imports: import logging
  from pathlib import Path
  import tempfile
  import pytest
  from huggingface_hub import HfApi, RepoUrl, GitRefs, GitRefInfo
  import torch
  from sentence_transformers import SentenceTransformer
  from sentence_transformers.models import Transformer, Pooling
label_desc: Use image node_id 3 for calling a global function with example usage: test_save_to_hub(monkeypatch, caplog) and returns: RepoUrl, GitRefs, GitRefs