class_docstr: Basic context manager for a ClientBuilder connection.
docstr: Disconnect Ray. If it's a ray client and created with `allow_multiple`,
  it will do nothing. For other cases this either disconnects from the
  remote Client Server or shuts the current driver down.
docstr_tok: ["Disconnect","Ray",".","If","it","'s","a","ray","client","and","created","with","`","allow_multiple","`",",","it","will","do","nothing",".","For","other","cases","this","either","disconnects","from","the","remote","Client","Server","or","shuts","the","current","driver","down","."]
code: def _disconnect_with_context(self, force_disconnect: bool) -> None:
      """
      Disconnect Ray. If it's a ray client and created with `allow_multiple`,
      it will do nothing. For other cases this either disconnects from the
      remote Client Server or shuts the current driver down.
      """
      if ray.util.client.ray.is_connected():
          if ray.util.client.ray.is_default() or force_disconnect:
              # This is the only client connection
              ray.util.client_connect.disconnect()
      elif ray._private.worker.global_worker.node is None:
          # Already disconnected.
          return
      elif ray._private.worker.global_worker.node.is_head():
          logger.debug(
              "The current Ray Cluster is scoped to this process. "
              "Disconnecting is not possible as it will shutdown the "
              "cluster."
          )
      else:
          # This is only a driver connected to an existing cluster.
          ray.shutdown()
  
imports: import importlib
  import inspect
  import json
  import logging
  import os
  import sys
  import warnings
  from dataclasses import dataclass
  from typing import Any, Dict, Optional, Tuple
  import ray.util.client_connect
  from ray._private.ray_constants import RAY_ADDRESS_ENVIRONMENT_VARIABLE, RAY_NAMESPACE_ENVIRONMENT_VARIABLE, RAY_RUNTIME_ENV_ENVIRONMENT_VARIABLE
  from ray._private.utils import check_ray_client_dependencies_installed, split_address
  from ray._private.worker import BaseContext
  from ray._private.worker import init
  from ray.job_config import JobConfig
  from ray.util.annotations import Deprecated, PublicAPI
label_desc: Use image node_id 5 for calling the ClientContext obj's underlying member method code with example usage: obj._disconnect_with_context(force_disconnect) without return types