code: def session_retry(retries=3, backoff_factor=0.3, status_forcelist=(500, 502, 504), session=None):
      
      session = session or Session()
      retries = Retry(
          total=retries,
          read=retries,
          connect=retries,
          backoff_factor=backoff_factor,
          status_forcelist=status_forcelist,
      )
      # mount all https requests
      session.mount('https://', adapters.HTTPAdapter(max_retries=retries))
      return session
docs: Add retry to Requests Session
  
      https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#urllib3.util.retry.Retry