code: def _handle_host_wandb_setting(
      host: Optional[str], cloud: bool = False
  ) -> None:
      """Write the host parameter to the global settings file.
  
      This takes the parameter from wandb.login or wandb login for use by the
      application's APIs.
      """
      _api = InternalApi()
      if host == "https://api.wandb.ai" or (host is None and cloud):
          _api.clear_setting("base_url", globally=True, persist=True)
          # To avoid writing an empty local settings file, we only clear if it exists
          if os.path.exists(OldSettings._local_path()):
              _api.clear_setting("base_url", persist=True)
      elif host:
          host = host.rstrip("/")
          # force relogin if host is specified
          _api.set_setting(
              "base_url", host, globally=True, persist=True
          )
  
imports: import enum
  import os
  import sys
  from typing import Dict, Optional, Tuple
  import click
  import wandb
  from wandb.errors import AuthenticationError, UsageError
  from wandb.old.settings import Settings
  from ..apis import InternalApi
  from .internal.internal_api import Api
  from .lib import apikey
  from .wandb_settings import Settings, Source
label_desc: Use image node_id 1 for calling a global function with example usage: _handle_host_wandb_setting(host, cloud) without return types