code: def connect_to_client_or_not(connect_to_client: bool):
      """Utility for running test logic with and without a Ray client connection.
  
      If client_connect is True, will connect to Ray client in context.
      If client_connect is False, does nothing.
  
      How to use:
      Given a test of the following form:
  
      def test_<name>(args):
          <initialize a ray cluster>
          <use the ray cluster>
  
      Modify the test to
  
      @pytest.mark.parametrize("connect_to_client", [False, True])
      def test_<name>(args, connect_to_client)
      <initialize a ray cluster>
      with connect_to_client_or_not(connect_to_client):
          <use the ray cluster>
  
      Parameterize the argument connect over True, False to run the test with and
      without a Ray client connection.
      """
  
      if connect_to_client:
          with ray_start_client_server(
              namespace=""
          ), enable_client_mode():
              yield
      else:
          yield
  
file_path: ray/python/ray/util/client/ray_client_helpers.py
imports: from contextlib import contextmanager
  import time
  from typing import Any, Dict
  import ray
  from ray.job_config import JobConfig
  import ray.util.client.server.server
  from ray.util.client import ray
  from ray._private.client_mode_hook import enable_client_mode, disable_client_hook
label_desc: Use image node_id 5 for calling a global function with example usage: connect_to_client_or_not(connect_to_client) without return types