code: def with_api_exceptions_handler(func):
      def wrapper(*args, **kwargs):
          last_exception = None
          start_time = time.monotonic()
          for retry in itertools.count(0):
              if time.monotonic() - start_time > retries_timeout:
                  break
  
              try:
                  return func(*args, **kwargs)
              except requests.exceptions.InvalidHeader as e:
                  if "X-Neptune-Api-Token" in e.args[0]:
                      raise NeptuneInvalidApiTokenException()
                  raise
              except (
                  BravadoConnectionError,
                  BravadoTimeoutError,
                  requests.exceptions.ConnectionError,
                  requests.exceptions.Timeout,
                  HTTPRequestTimeout,
                  HTTPServiceUnavailable,
                  HTTPGatewayTimeout,
                  HTTPBadGateway,
                  HTTPInternalServerError,
                  NewConnectionError,
                  ChunkedEncodingError,
                  requests.exceptions.SSLError,
                  RecursiveCallException,
              ) as e:
                  time.sleep(
                      min(
                          2 ** min(MAX_RETRY_MULTIPLIER, retry),
                          MAX_RETRY_TIME,
                      )
                  )
                  last_exception = e
                  continue
              except HTTPTooManyRequests as e:
                  wait_time = get_retry_from_headers_or_default(
                      e.response.headers, retry
                  )
                  time.sleep(wait_time)
                  last_exception = e
                  continue
              except NeptuneAuthTokenExpired as e:
                  last_exception = e
                  continue
              except HTTPUnauthorized:
                  raise Unauthorized()
              except HTTPForbidden:
                  raise Forbidden()
              except HTTPClientError as e:
                  raise ClientHttpError(
                      e.status_code, e.response.text
                  ) from e
              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,
                  ):
                      time.sleep(
                          min(
                              2 ** min(MAX_RETRY_MULTIPLIER, retry),
                              MAX_RETRY_TIME,
                          )
                      )
                      last_exception = e
                      continue
                  elif status_code == HTTPTooManyRequests.status_code:
                      wait_time = get_retry_from_headers_or_default(
                          e.response.headers, retry
                      )
                      time.sleep(wait_time)
                      last_exception = e
                      continue
                  elif status_code == HTTPUnauthorized.status_code:
                      raise Unauthorized()
                  elif status_code == HTTPForbidden.status_code:
                      raise Forbidden()
                  elif 400 <= status_code < 500:
                      raise ClientHttpError(
                          status_code, e.response.text
                      ) from e
                  else:
                      raise
          raise NeptuneConnectionLostException(
              last_exception
          ) from last_exception
  
      return wrapper
  
file_path: neptune-client/src/neptune/common/backends/utils.py
imports: import itertools
  import logging
  import os
  import time
  import requests
  from bravado.exception import BravadoConnectionError, BravadoTimeoutError, HTTPBadGateway, HTTPClientError, HTTPForbidden, HTTPGatewayTimeout, HTTPInternalServerError, HTTPRequestTimeout, HTTPServiceUnavailable, HTTPTooManyRequests, HTTPUnauthorized
  from bravado_core.util import RecursiveCallException
  from requests.exceptions import ChunkedEncodingError
  from urllib3.exceptions import NewConnectionError
  from neptune.common.envs import NEPTUNE_RETRIES_TIMEOUT_ENV
  from neptune.common.exceptions import ClientHttpError, Forbidden, NeptuneAuthTokenExpired, NeptuneConnectionLostException, NeptuneInvalidApiTokenException, Unauthorized
label_desc: Use image node_id 2 for calling a global function with example usage: with_api_exceptions_handler(func) and returns: wrapper, func