code: def legacy_with_api_exceptions_handler(func):
      def wrapper(*args, **kwargs):
          retries = 11
          retry = 0
          while retry < retries:
              try:
                  return func(*args, **kwargs)
              except requests.exceptions.SSLError:
                  raise NeptuneSSLVerificationError()
              except HTTPServiceUnavailable:
                  if retry >= 6:
                      _logger.warning(
                          "Experiencing connection interruptions. Reestablishing communication with Neptune."
                      )
                  time.sleep(2**retry)
                  retry += 1
                  continue
              except (
                  BravadoConnectionError,
                  BravadoTimeoutError,
                  requests.exceptions.ConnectionError,
                  requests.exceptions.Timeout,
                  HTTPRequestTimeout,
                  HTTPGatewayTimeout,
                  HTTPBadGateway,
                  HTTPInternalServerError,
                  NewConnectionError,
              ):
                  if retry >= 6:
                      _logger.warning(
                          "Experiencing connection interruptions. Reestablishing communication with Neptune."
                      )
                  time.sleep(2**retry)
                  retry += 1
                  continue
              except HTTPTooManyRequests as e:
                  wait_time = get_retry_from_headers_or_default(
                      e.response.headers, retry
                  )
                  time.sleep(wait_time)
                  retry += 1
                  continue
              except HTTPUnauthorized:
                  raise Unauthorized()
              except HTTPForbidden:
                  raise Forbidden()
              except requests.exceptions.RequestException as e:
                  if e.response is None:
                      raise
                  status_code = e.response.status_code
                  if status_code in (
                      HTTPRequestTimeout.status_code,
                      HTTPBadGateway.status_code,
                      HTTPServiceUnavailable.status_code,
                      HTTPGatewayTimeout.status_code,
                      HTTPInternalServerError.status_code,
                  ):
                      if retry >= 6:
                          _logger.warning(
                              "Experiencing connection interruptions. Reestablishing communication with Neptune."
                          )
                      time.sleep(2**retry)
                      retry += 1
                      continue
                  elif status_code == HTTPTooManyRequests.status_code:
                      wait_time = get_retry_from_headers_or_default(
                          e.response.headers, retry
                      )
                      time.sleep(wait_time)
                      retry += 1
                      continue
                  elif (
                      status_code >= HTTPInternalServerError.status_code
                  ):
                      raise ServerError()
                  elif status_code == HTTPUnauthorized.status_code:
                      raise Unauthorized()
                  elif status_code == HTTPForbidden.status_code:
                      raise Forbidden()
                  else:
                      raise
          raise ConnectionLost()
  
      return wrapper
  
file_path: neptune-client/src/neptune/legacy/internal/api_clients/hosted_api_clients/utils.py
imports: import logging
  import time
  import requests
  from bravado.exception import BravadoConnectionError, BravadoTimeoutError, HTTPBadGateway, HTTPForbidden, HTTPGatewayTimeout, HTTPInternalServerError, HTTPRequestTimeout, HTTPServiceUnavailable, HTTPTooManyRequests, HTTPUnauthorized
  from urllib3.exceptions import NewConnectionError
  from neptune.common.backends.utils import get_retry_from_headers_or_default
  from neptune.legacy.api_exceptions import ConnectionLost, Forbidden, NeptuneSSLVerificationError, ServerError, Unauthorized
label_desc: Use image node_id 1 for calling a global function with example usage: legacy_with_api_exceptions_handler(func) and returns: wrapper, func