class_docstr: A datasource that lets you read images.
class_docstr_tok: ["A","datasource","that","lets","you","read","images","."]
code: def __init__(
      self,
      paths: Union[str, List[str]],
      size: Optional[Tuple[int, int]] = None,
      mode: Optional[str] = None,
      **file_based_datasource_kwargs,
  ):
      super().__init__(paths, **file_based_datasource_kwargs)
  
      _check_import(self, module="PIL", package="Pillow")
  
      if size is not None and len(size) != 2:
          raise ValueError(
              "Expected `size` to contain two integers for height and width, "
              f"but got {len(size)} integers instead."
          )
  
      if size is not None and (size[0] < 0 or size[1] < 0):
          raise ValueError(
              f"Expected `size` to contain positive integers, but got {size} instead."
          )
  
      self.size = size
      self.mode = mode
  
      meta_provider = file_based_datasource_kwargs.get(
          "meta_provider", None
      )
      if isinstance(meta_provider, _ImageFileMetadataProvider):
          self._encoding_ratio = self._estimate_files_encoding_ratio()
          meta_provider._set_encoding_ratio(self._encoding_ratio)
      else:
          self._encoding_ratio = IMAGE_ENCODING_RATIO_ESTIMATE_DEFAULT
  
imports: import io
  import logging
  import time
  from typing import TYPE_CHECKING, Iterator, List, Optional, Tuple, Union
  import numpy
  from ray.data._internal.delegating_block_builder import DelegatingBlockBuilder
  from ray.data._internal.util import _check_import
  from ray.data.block import Block, BlockMetadata
  from ray.data.datasource.file_based_datasource import FileBasedDatasource
  from ray.data.datasource.file_meta_provider import DefaultFileMetadataProvider
  from ray.util.annotations import DeveloperAPI
label_desc: Use image node_id 1 to create a new ImageDatasource object from inherited base classes: FileBasedDatasource with example: obj = ImageDatasource(paths, size, mode)