code: def exception_retry_middleware(make_request, web3, errors, retries=5):
      
      def middleware(method, params):
          if check_if_retry_on_failure(method):
              for i in range(retries):
                  try:
                      return make_request(method, params)
                  except errors:
                      if i < retries - 1:
                          continue
                      else:
                          raise
          else:
              return make_request(method, params)
      return middleware
docs: Creates middleware that retries failed HTTP requests. Is a default
      middleware for HTTPProvider.