code: def _retry(conf, f):
      start = datetime.datetime.now()
      delay = 0
      for n in itertools.count(1):
          try:
              return f()
          except Exception as error:
              raised_after = datetime.datetime.now() - start
              if conf.handle_error:
                  conf.handle_error(error, n, raised_after)
              delay = conf.get_delay(n, raised_after, delay)
              retry_after = raised_after + datetime.timedelta(
                  seconds=delay
              )
              retrying = (
                  conf.retriable(error)
                  and (conf.max_times is None or n <= conf.max_times)
                  and (
                      conf.max_time is None
                      or retry_after <= conf.max_time
                  )
              )
              if not retrying:
                  raise
              if delay:
                  conf.sleep(delay)
              if conf.logger:
                  conf.logger.warning(
                      "Retrying (try %d) after %s (%s + %s sec) on %s: %s",
                      n,
                      retry_after,
                      raised_after,
                      delay,
                      error.__class__.__name__,
                      error,
                      exc_info=True,
                  )
  
imports: import copy
  import datetime
  import functools
  import itertools
  import logging
  import random
  import time
label_desc: Use image node_id 4 for calling a global function with example usage: _retry(conf, f) and returns: f