class_docstr: Image [`Feature`] to read image data from an image file.
  
  Input: The Image feature accepts as input:
  - A `str`: Absolute path to the image file (i.e. random access is allowed).
  - A `dict` with the keys:
  
      - `path`: String with relative path of the image file to the archive file.
      - `bytes`: Bytes of the image file.
  
    This is useful for archived files with sequential access.
  
  - An `np.ndarray`: NumPy array representing an image.
  - A `PIL.Image.Image`: PIL image object.
  
  Args:
      decode (`bool`, defaults to `True`):
          Whether to decode the image data. If `False`,
          returns the underlying dictionary in the format `{"path": image_path, "bytes": image_bytes}`.
  
  Examples:
  
  ```py
  >>> from datasets import load_dataset, Image
  >>> ds = load_dataset("beans", split="train")
  >>> ds.features["image"]
  Image(decode=True, id=None)
  >>> ds[0]["image"]
  <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=500x500 at 0x15E52E7F0>
  >>> ds = ds.cast_column('image', Image(decode=False))
  {'bytes': None,
   'path': '/root/.cache/huggingface/datasets/downloads/extracted/b0a21163f78769a2cf11f58dfc767fb458fc7cea5c05dccc0144a2c0f0bc1292/train/healthy/healthy_train.85.jpg'}
  ```
class_docstr_tok: ["Image","[","`","Feature","`","]","to","read","image","data","from","an","image","file",".","Input",":","The","Image","feature","accepts","as","input",":","-","A","`","str","`",":","Absolute","path","to","the","image","file","(","i.e",".","random","access","is","allowed",")",".","-","A","`","dict","`","with","the","keys",":","-","`","path","`",":","String","with","relative","path","of","the","image","file","to","the","archive","file",".","-","`","bytes","`",":","Bytes","of","the","image","file",".","This","is","useful","for","archived","files","with","sequential","access",".","-","An","`","np.ndarray","`",":","NumPy","array","representing","an","image",".","-","A","`","PIL.Image.Image","`",":","PIL","image","object",".","Args",":","decode","(","`","bool","`",",","defaults","to","`","True","`",")",":","Whether","to","decode","the","image","data",".","If","`","False","`",",","returns","the","underlying","dictionary","in","the","format","`","{","``","path","''",":","image_path",",","``","bytes","''",":","image_bytes","}","`",".","Examples",":","``","`","py",">",">",">","from","datasets","import","load_dataset",",","Image",">",">",">","ds","=","load_dataset","(","``","beans","''",",","split=","''","train","''",")",">",">",">","ds.features","[","``","image","''","]","Image","(","decode=True",",","id=None",")",">",">",">","ds","[","0","]","[","``","image","''","]","<","PIL.JpegImagePlugin.JpegImageFile","image","mode=RGB","size=500x500","at","0x15E52E7F0",">",">",">",">","ds","=","ds.cast_column","(","'image","'",",","Image","(","decode=False",")",")","{","'bytes","'",":","None",",","'path","'",":","'\/root\/.cache\/huggingface\/datasets\/downloads\/extracted\/b0a21163f78769a2cf11f58dfc767fb458fc7cea5c05dccc0144a2c0f0bc1292\/train\/healthy\/healthy_train.85.jpg","'","}","``","`"]
docstr: Embed image files into the Arrow array.
  
  Args:
      storage (`pa.StructArray`):
          PyArrow array to embed.
  
  Returns:
      `pa.StructArray`: Array in the Image arrow storage type, that is
          `pa.struct({"bytes": pa.binary(), "path": pa.string()})`.
docstr_tok: ["Embed","image","files","into","the","Arrow","array",".","Args",":","storage","(","`","pa.StructArray","`",")",":","PyArrow","array","to","embed",".","Returns",":","`","pa.StructArray","`",":","Array","in","the","Image","arrow","storage","type",",","that","is","`","pa.struct","(","{","``","bytes","''",":","pa.binary","(",")",",","``","path","''",":","pa.string","(",")","}",")","`","."]
code: def embed_storage(self, storage: pa.StructArray) -> pa.StructArray:
      """Embed image files into the Arrow array.
  
      Args:
          storage (`pa.StructArray`):
              PyArrow array to embed.
  
      Returns:
          `pa.StructArray`: Array in the Image arrow storage type, that is
              `pa.struct({"bytes": pa.binary(), "path": pa.string()})`.
      """
  
      @no_op_if_value_is_null
      def path_to_bytes(path):
          with xopen(path, "rb") as f:
              bytes_ = f.read()
          return bytes_
  
      bytes_array = pa.array(
          [
              (
                  path_to_bytes(x["path"])
                  if x["bytes"] is None
                  else x["bytes"]
              )
              if x is not None
              else None
              for x in storage.to_pylist()
          ],
          type=pa.binary(),
      )
      path_array = pa.array(
          [
              os.path.basename(path) if path is not None else None
              for path in storage.field("path").to_pylist()
          ],
          type=pa.string(),
      )
      storage = pa.StructArray.from_arrays(
          [bytes_array, path_array],
          ["bytes", "path"],
          mask=bytes_array.is_null(),
      )
      return array_cast(storage, self.pa_type)
  
imports: import os
  import sys
  import warnings
  from dataclasses import dataclass, field
  from io import BytesIO
  from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union
  import numpy
  import pyarrow
  from ..None import config
  from ..download.download_config import DownloadConfig
  from ..download.streaming_download_manager import xopen
  from ..table import array_cast
  from ..utils.file_utils import is_local_path
  from ..utils.py_utils import first_non_null_value, no_op_if_value_is_null, string_to_dict
label_desc: Use image node_id 6 for calling the Image obj's underlying member method code with example usage: obj.embed_storage(storage) and returns: array_cast, bytes_