code: def determined_test_session(
      credentials: Optional[authentication.Credentials] = None,
      admin: Optional[bool] = None,
  ) -> api.Session:
      assert (
          admin is None or credentials is None
      ), "admin and credentials are mutually exclusive"
  
      if credentials is None:
          if admin:
              credentials = conf.ADMIN_CREDENTIALS
          else:
              credentials = authentication.Credentials("determined", "")
  
      murl = conf.make_master_url()
      certs.cli_cert = certs.default_load(murl)
      authentication.cli_auth = authentication.Authentication(
          murl,
          requested_user=credentials.username,
          password=credentials.password,
      )
      return api.Session(
          murl,
          credentials.username,
          authentication.cli_auth,
          certs.cli_cert,
      )
  
imports: import uuid
  from typing import Callable, Optional, Sequence, TypeVar
  import pytest
  from determined.common import api
  from determined.common.api import authentication, bindings, certs, errors
  from tests import config
label_desc: Use image node_id 2 for calling a global function with example usage: determined_test_session(credentials, admin) and returns: api