code: def __next__(self):
      if len(self.entries) == 0:
          # stop iteration if the last chunk was smaller than the page size
          if self.last_chunk_size < self.page_size:
              raise StopIteration
          chunk = retry(
              self.fn,
              page_offset=self.offset * self.page_size,
              page_size=self.page_size,
              *self.args,
              **self.kwargs,
          )
          if len(chunk) == 0:
              raise StopIteration
          self.offset += 1
          self.last_chunk_size = len(chunk)
          # Handle the case where the chunk is a string. In this case we want
          # to return the whole page as a single string instead of an interable
          # of characters.
          chunk = chunk if not isinstance(chunk, str) else [chunk]
          self.entries.extend(chunk)
      return self.entries.pop(0)
  
imports: import io
  import os
  import random
  import threading
  import time
  from enum import Enum
  from typing import Iterator, List, Optional
  from PIL import JpegImagePlugin
  from lightly.openapi_generated.swagger_client.configuration import Configuration
label_desc: Use image node_id 3 for calling the Paginated obj's underlying member method code with example usage: obj.__next__() and returns: self