code: def read_paginated(
      get_with_offset: Callable[[int], T],
      offset: int = 0,
      pages: PageOpts = PageOpts.all,
  ) -> Iterator[T]:
      while True:
          resp = get_with_offset(offset)
          pagination = resp.pagination
          assert pagination is not None
          assert pagination.endIndex is not None
          assert pagination.total is not None
          yield resp
          if (
              pagination.endIndex >= pagination.total
              or pages == PageOpts.single
          ):
              break
          assert pagination.endIndex is not None
          offset = pagination.endIndex
  
file_path: determined/harness/determined/common/api/_util.py
imports: import enum
  from typing import Callable, Iterator, Optional, Tuple, TypeVar, Union
  import urllib3
  from determined.common import api, util
  from determined.common.api import bindings
label_desc: Use image node_id 1 for calling a global function with example usage: read_paginated(get_with_offset, offset, pages) without return types