code: def check_remote_repo_credentials(
      repo_data: RemoteRunRepoData,
      protocol: RepoProtocol,
      *,
      identity_file: Optional[PathLike] = None,
      oauth_token: Optional[str] = None,
  ) -> RemoteRepoCreds:
      url = repo_data.make_url(protocol, oauth_token)
      if protocol == RepoProtocol.HTTPS:
          git.cmd.Git().ls_remote(
              url, env=dict(GIT_TERMINAL_PROMPT="0")
          )
          return RemoteRepoCreds(
              protocol=protocol,
              oauth_token=oauth_token,
              private_key=None,
          )
      elif protocol == RepoProtocol.SSH:
          if not Path(identity_file).exists():
              raise InvalidRepoCredentialsError(
                  f"The {identity_file} private SSH key doesn't exist"
              )
          if not os.access(identity_file, os.R_OK):
              raise InvalidRepoCredentialsError(
                  f"Can't access the {identity_file} private SSH key"
              )
          if not try_ssh_key_passphrase(identity_file):
              raise InvalidRepoCredentialsError(
                  f"Can't access `{url}`: ensure the `{identity_file}` private SSH key is valid and passphrase-free"
              )
          with open(identity_file, "r") as f:
              private_key = f.read()
          git.cmd.Git().ls_remote(
              url,
              env=dict(
                  GIT_SSH_COMMAND=make_ssh_command_for_git(
                      identity_file
                  )
              ),
          )
          return RemoteRepoCreds(
              protocol=protocol,
              private_key=private_key,
              oauth_token=None,
          )
  
file_path: dstack/src/dstack/_internal/core/services/repos.py
imports: import os
  from pathlib import Path
  from typing import Optional, Union
  import git
  import requests
  import yaml
  from git.exc import GitCommandError
  from dstack._internal.core.errors import DstackError
  from dstack._internal.core.models.config import RepoConfig
  from dstack._internal.core.models.repos import LocalRepo, RemoteRepo, RemoteRepoCreds, RemoteRunRepoData
  from dstack._internal.core.models.repos.base import Repo, RepoProtocol
  from dstack._internal.utils.path import PathLike
  from dstack._internal.utils.ssh import get_host_config, make_ssh_command_for_git, try_ssh_key_passphrase
label_desc: Use image node_id 2 for calling a global function with example usage: check_remote_repo_credentials(repo_data, protocol) and returns: RemoteRepoCreds, RemoteRepoCreds