code: def retry(func, *args, **kwargs):  # type: ignore
      """Repeats a function until it completes successfully or fails too often.
  
      Args:
          func:
              The function call to repeat.
          args:
              The arguments which are passed to the function.
          kwargs:
              Key-word arguments which are passed to the function.
  
      Returns:
          What func returns.
  
      Exceptions:
          RuntimeError when number of retries has been exceeded.
  
      """
  
      # config
      backoff = 1.0 + random.random() * 0.1
      max_backoff = RETRY_MAX_BACKOFF
      max_retries = RETRY_MAX_RETRIES
  
      # try to make the request
      current_retries = 0
      while True:
          try:
              # return on success
              return func(*args, **kwargs)
          except Exception as e:
              # sleep on failure
              time.sleep(backoff)
              backoff = (
                  2 * backoff if backoff < max_backoff else backoff
              )
              current_retries += 1
  
              # max retries exceeded
              if current_retries >= max_retries:
                  raise RuntimeError(
                      f"Maximum retries exceeded! Original exception: {type(e)}: {str(e)}"
                  ) from e
  
imports: import io
  import os
  import random
  import threading
  import time
  from enum import Enum
  from typing import Iterator, List, Optional
  from PIL import JpegImagePlugin
  from lightly.openapi_generated.swagger_client.configuration import Configuration
label_desc: Use image node_id 1 for calling a global function with example usage: retry(func) and returns: func