code: def poll_until_ready_and_assert(
      relative_url: str,
      expected_status_code: int = 200,
      expected_error_code: Optional[str] = None,
      headers: Optional[Headers] = None,
      url: str = URL,
      check_x_revision: bool = False,
      dataset: Optional[str] = None,
  ) -> Any:
      interval = INTERVAL
      timeout = MAX_DURATION
      retries = timeout // interval
      should_retry = True
      response = None
      while retries > 0 and should_retry:
          retries -= 1
          time.sleep(interval)
          response = get(
              relative_url=relative_url, headers=headers, url=url
          )
          print(response.headers.get("X-Error-Code"))
          should_retry = response.headers.get("X-Error-Code") in [
              "ResponseNotReady",
              "ResponseAlreadyComputedError",
          ]
      if retries == 0 or response is None:
          raise RuntimeError("Poll timeout")
      assert response.status_code == expected_status_code, log(
          response, url, relative_url, dataset
      )
      assert (
          response.headers.get("X-Error-Code") == expected_error_code
      ), log(response, url, relative_url)
      if check_x_revision:
          assert response.headers.get("X-Revision") is not None, log(
              response, url, relative_url
          )
          assert (
              len(str(response.headers.get("X-Revision"))) == 40
          ), log(response, url, relative_url)
      return response
  
imports: import json
  import os
  import re
  import time
  from collections.abc import Iterator, Mapping
  from contextlib import contextmanager, suppress
  from pathlib import Path
  from typing import Any, Optional
  import requests
  from huggingface_hub.hf_api import HfApi
  from huggingface_hub.utils._errors import hf_raise_for_status
  from requests import Response
  from .constants import CI_HUB_ENDPOINT
label_desc: Use image node_id 11 for calling a global function with example usage: poll_until_ready_and_assert(relative_url, expected_status_code, expected_error_code, headers, url, check_x_revision, dataset) and returns: response