code: def retry_if_request_failed(
      result: Union[RequestResult, TokenizationRequestResult]
  ) -> bool:
      """Fails if `success` of `RequestResult` or `TokenizationRequestResult` is false."""
      if not result.success:
          hlog(result.error)
      retry_if_fail: bool = True
      if isinstance(result, RequestResult):
          retry_if_fail = (
              result.error_flags is None
              or result.error_flags.is_retriable is None
              or result.error_flags.is_retriable
          )
      return not result.success and retry_if_fail
  
imports: from typing import Callable, Union
  from retrying import Retrying
  from helm.common.request import RequestResult
  from helm.common.tokenization_request import TokenizationRequestResult
  from helm.common.hierarchical_logger import hlog
label_desc: Use image node_id 2 for calling a global function with example usage: retry_if_request_failed(result) and returns: unknown