code: def login(
      api_url: str,
      api_key: str,
      workspace: Optional[str] = None,
      extra_headers: Optional[Dict[str, str]] = None,
  ) -> None:
      """Login to an Argilla server using the provided URL and API key. If the login is successful, the credentials will
      be stored in the Argilla cache directory (`~/.cache/argilla/credentials.json`).
  
      Args:
          api_url: The URL of the Argilla server.
          api_key: The API key to use when communicating with the Argilla server.
          workspace: The default workspace where the datasets will be created.
          extra_headers: A dictionary containing extra headers that will be sent to the Argilla server.
  
      Raises:
          ValueError: If the login fails.
      """
      # Try to login to the server
      try:
          init(
              api_url=api_url,
              api_key=api_key,
              workspace=workspace,
              extra_headers=extra_headers,
          )
      except HttpResponseError as e:
          raise ValueError(
              f"Could not reach '{api_url}', make sure that the Argilla Server is running and working as expected"
          ) from e
      except UnauthorizedApiError as e:
          raise ValueError(
              f"Could not login in '{api_url}' using provided credentials"
          ) from e
  
      if not ARGILLA_CACHE_DIR.exists():
          ARGILLA_CACHE_DIR.mkdir(parents=True)
  
      ArgillaCredentials(
          api_url=api_url,
          api_key=api_key,
          workspace=workspace,
          extra_headers=extra_headers,
      ).save()
  
file_path: argilla/src/argilla/client/login.py
imports: from pathlib import Path
  from typing import Dict, Optional
  from argilla.client.sdk.commons.errors import HttpResponseError, UnauthorizedApiError
  from argilla.client.singleton import init
  from argilla.pydantic_v1 import AnyHttpUrl, BaseModel
label_desc: Use image node_id 1 for calling a global function with example usage: login(api_url, api_key, workspace, extra_headers) without return types