code: def browser_login(clearml_server=None):
      # type: (Optional[str]) -> ()
      """
      Alternative authentication / login method, (instead of configuring ~/clearml.conf or Environment variables)
      ** Only applicable when running inside a browser session,
      for example Google Colab, Kaggle notebook, Jupyter Notebooks etc. **
  
      Notice: If called inside a python script, or when running with an agent, this function is ignored
  
      :param clearml_server: Optional, set the clearml server address, default: https://app.clear.ml
      """
  
      # check if we are running inside a Jupyter notebook of a sort
      if not os.environ.get("JPY_PARENT_PID"):
          return
  
      # if we are running remotely or in offline mode, skip login
      from clearml.config import running_remotely
  
      # noinspection PyProtectedMember
      if running_remotely():
          return
  
      # if we have working local configuration, nothing to do
      try:
          Session()
          # make sure we set environment variables to point to our api/app/files hosts
          ENV_WEB_HOST.set(Session.get_app_server_host())
          ENV_HOST.set(Session.get_api_server_host())
          ENV_FILES_HOST.set(Session.get_files_server_host())
          return
      except:  # noqa
          pass
  
      # conform clearml_server address
      if clearml_server:
          if not clearml_server.lower().startswith("http"):
              clearml_server = "http://{}".format(clearml_server)
  
          parsed = urlparse(clearml_server)
          if parsed.port:
              parsed = parsed._replace(
                  netloc=parsed.netloc.replace(
                      ":%d" % parsed.port, ":8008", 1
                  )
              )
  
          if parsed.netloc.startswith("demoapp."):
              parsed = parsed._replace(
                  netloc=parsed.netloc.replace(
                      "demoapp.", "demoapi.", 1
                  )
              )
          elif parsed.netloc.startswith("app."):
              parsed = parsed._replace(
                  netloc=parsed.netloc.replace("app.", "api.", 1)
              )
          elif parsed.netloc.startswith("api."):
              pass
          else:
              parsed = parsed._replace(netloc="api." + parsed.netloc)
  
          clearml_server = urlunparse(parsed)
  
          # set for later usage
          ENV_HOST.set(clearml_server)
  
      token = None
      counter = 0
      clearml_app_server = Session.get_app_server_host()
      while not token:
          # try to get authentication toke
          try:
              # noinspection PyProtectedMember
              token = Session._Session__get_browser_token(
                  clearml_app_server
              )
          except ValueError:
              token = None
          except Exception:  # noqa
              token = None
          # if we could not get a token, instruct the user to login
          if not token:
              if not counter:
                  print(
                      "ClearML automatic browser login failed, please login or create a new account\n"
                      "To get started with ClearML: setup your own `clearml-server`, "
                      "or create a free account at {}\n".format(
                          clearml_app_server
                      )
                  )
                  print(
                      "Please login to {} , then press [Enter] to connect ".format(
                          clearml_app_server
                      ),
                      end="",
                  )
                  input()
              elif counter < 1:
                  print(
                      "Oh no we failed to connect \N{worried face}, "
                      "try to logout and login again - Press [Enter] to retry ",
                      end="",
                  )
                  input()
              else:
                  print(
                      "\n"
                      "We cannot connect automatically (adblocker / incognito?) \N{worried face} \n"
                      "Please go to {}/settings/workspace-configuration \n"
                      "Then press \x1B[1m\x1B[48;2;26;30;44m\x1B[37m + Create new credentials \x1b[0m \n"
                      "And copy/paste your \x1B[1m\x1B[4mAccess Key\x1b[0m here: ".format(
                          clearml_app_server.lstrip("/")
                      ),
                      end="",
                  )
  
                  creds = input()
                  if creds:
                      print(" Setting access key ")
                      ENV_ACCESS_KEY.set(creds.strip())
  
                  print(
                      "Now copy/paste your \x1B[1m\x1B[4mSecret Key\x1b[0m here: ",
                      end="",
                  )
                  creds = input()
                  if creds:
                      print(" Setting secret key ")
                      ENV_SECRET_KEY.set(creds.strip())
  
                  if ENV_ACCESS_KEY.get() and ENV_SECRET_KEY.get():
                      # store in conf file for persistence in runtime
                      # noinspection PyBroadException
                      try:
                          with open(get_config_file(), "wt") as f:
                              f.write(
                                  "api.credentials.access_key={}\napi.credentials.secret_key={}\n".format(
                                      ENV_ACCESS_KEY.get(),
                                      ENV_SECRET_KEY.get(),
                                  )
                              )
                      except Exception:
                          pass
                      break
  
              counter += 1
  
      print("")
      if counter:
          # these emojis actually requires python 3.6+
          # print("\nHurrah! \N{face with party horn and party hat} \N{confetti ball} \N{party popper}")
          print("\nHurrah! \U0001f973 \U0001f38a \U0001f389")
  
      if token:
          # set Token
          ENV_AUTH_TOKEN.set(token)
  
      if token or (ENV_ACCESS_KEY.get() and ENV_SECRET_KEY.get()):
          # make sure we set environment variables to point to our api/app/files hosts
          ENV_WEB_HOST.set(Session.get_app_server_host())
          ENV_HOST.set(Session.get_api_server_host())
          ENV_FILES_HOST.set(Session.get_files_server_host())
          # verify token
          Session()
          # success
          print(
              "\N{robot face} ClearML connected successfully - let's build something! \N{rocket}"
          )
  
imports: from __future__ import print_function
  import json
  import logging
  import os
  import sys
  import types
  import weakref
  from socket import gethostname
  from time import sleep
  import jwt
  import requests
  import six
  from requests.auth import HTTPBasicAuth
  from requests.exceptions import ChunkedEncodingError, ContentDecodingError, StreamConsumedError
  from six.moves.urllib.parse import urlparse, urlunparse
  from typing import List, Optional
  from .callresult import CallResult
  from .defs import ENV_VERBOSE, ENV_HOST, ENV_ACCESS_KEY, ENV_SECRET_KEY, ENV_WEB_HOST, ENV_FILES_HOST, ENV_OFFLINE_MODE, ENV_AUTH_TOKEN, ENV_DISABLE_VAULT_SUPPORT, ENV_ENABLE_ENV_CONFIG_SECTION, ENV_ENABLE_FILES_CONFIG_SECTION, ENV_API_EXTRA_RETRY_CODES, ENV_API_DEFAULT_REQ_METHOD, ENV_FORCE_MAX_API_VERSION, ENV_IGNORE_MISSING_CONFIG, MissingConfigError
  from .request import Request, BatchRequest
  from .token_manager import TokenManager
  from ..utils import get_http_session_with_retry, urllib_log_warning_setup
  from ...backend_config import ConfigurationError
  from ...backend_config.defs import get_config_file
  from ...debugging import get_logger
  from ...debugging.log import resolve_logging_level
  from ...utilities.pyhocon import ConfigTree, ConfigFactory
  from ...version import __version__
  from ...backend_config.utils import apply_files, apply_environment
label_desc: Use image node_id 1 for calling a global function with example usage: browser_login(clearml_server) without return types