code: def warnings_on_slow_request(
      *, address: str, endpoint: str, timeout: float, explain: bool
  ):
      """A context manager to print warnings if the request is replied slowly.
  
      Warnings are printed 3 times
  
      Args:
          address: The address of the endpoint.
          endpoint: The name of the endpoint.
          timeout: Request timeout in seconds.
          explain: Whether ot not it will print the warning.
      """
      # Do nothing if explain is not specified.
      if not explain:
          yield
          return
  
      # Prepare timers to print warning.
      # Print 3 times with exponential backoff. timeout / 2, timeout / 4, timeout / 8
      def print_warning(elapsed: float):
          logger.info(
              f"({round(elapsed, 2)} / {timeout} seconds) "
              "Waiting for the response from the API server "
              f"address {address}{endpoint}.",
          )
  
      warning_timers = [
          threading.Timer(
              timeout / i, print_warning, args=[timeout / i]
          )
          for i in [2, 4, 8]
      ]
  
      try:
          for timer in warning_timers:
              timer.start()
          yield
      finally:
          # Make sure all timers are cancelled once request is terminated.
          for timer in warning_timers:
              timer.cancel()
  
imports: import logging
  import threading
  import urllib
  import warnings
  from contextlib import contextmanager
  from dataclasses import fields
  from typing import Any, Dict, Generator, List, Optional, Tuple, Union
  import requests
  from ray.dashboard.modules.dashboard_sdk import SubmissionClient
  from ray.dashboard.utils import get_address_for_submission_client, ray_address_to_api_server_url
  from ray.util.annotations import DeveloperAPI
  from ray.util.state.common import DEFAULT_LIMIT, DEFAULT_RPC_TIMEOUT, ActorState, ClusterEventState, GetApiOptions, GetLogOptions, JobState, ListApiOptions, NodeState, ObjectState, PlacementGroupState, PredicateType, RuntimeEnvState, StateResource, SummaryApiOptions, SummaryResource, SupportedFilterType, TaskState, WorkerState, dict_to_state
  from ray.util.state.exception import RayStateApiException, ServerUnavailable
label_desc: Use image node_id 1 for calling a global function with example usage: warnings_on_slow_request() without return types