code: def retry_n(
      n: int, fn: Callable, *args, log_tries=False, **kwargs
  ) -> Any:
      """Retries a function n times with increasing exponentionally
      increasing sleep intervals in between. First argument is number of tries
      if n==1, means function will be called at least twice, first is try, second
      is retry. Second argument is the function itself, rest of the arguments and
      keyword arguments are passed to the function directly. Returns the output
      of the function directly. if failed after n retries, the exception will be
      raised.
  
      Args:
          n (int): Number of tries to be made
          fn (Callable): Function to be called
          log_tries (bool): If the function should log the try iteration. Default: False
  
      Returns:
          Any: Output from fn
      """
      completed = False
      count = 0
      output = None
  
      while not completed:
          try:
              output = fn(*args, **kwargs)
              completed = True
          except Exception:
              if count < n:
                  if log_tries:
                      logger.info(
                          f"Try {count + 1}/{n} failed for {fn.__name__}. Will retry "
                          f"after {2 ** count} second(s)."
                      )
                  time.sleep(2**count)
                  count += 1
              else:
                  raise
  
      return output
  
imports: import collections
  import gc
  import logging
  import math
  import os
  import sys
  import time
  import warnings
  from bisect import bisect
  from typing import Any, Callable, Dict
  import torch
  from mmf.utils.distributed import get_rank, get_world_size, is_xla
  from mmf.utils.file_io import PathManager
  from packaging import version
  from torch import nn, Tensor
label_desc: Use image node_id 27 for calling a global function with example usage: retry_n(n, fn) and returns: output