class_docstr: Creates an image component that can be used to upload and edit images (as an input) or display images (as an output).
  Preprocessing: passes the uploaded images as a dictionary with keys: `background`, `layers`, and `composite`. The values corresponding to `background` and `composite` are images, while `layers` is a list of images. The images are of type PIL.Image, np.array, or str filepath, depending on the `type` parameter.
  Postprocessing: expects a dictionary with keys: `background`, `layers`, and `composite`. The values corresponding to `background` and `composite` should be images or None, while `layers` should be a list of images. Images can be of type PIL.Image, np.array, or str filepath/URL. Or, the value can be simply a single image, in which case it will be used as the background.
  Examples-format: a dictionary with keys: `background`, `layers`, and `composite`. The values corresponding to `background` and `composite` should be strings or None, while `layers` should be a list of strings. The image corresponding to `composite`, if not None, is used as the example image. Otherwise, the image corresonding to `background` is used. The strings should be filepaths or URLs. Or, the value can be simply a single string filepath/URL to an image, which is used directly as the example image.
  Demos: image_editor
class_docstr_tok: ["Creates","an","image","component","that","can","be","used","to","upload","and","edit","images","(","as","an","input",")","or","display","images","(","as","an","output",")",".","Preprocessing",":","passes","the","uploaded","images","as","a","dictionary","with","keys",":","`","background","`",",","`","layers","`",",","and","`","composite","`",".","The","values","corresponding","to","`","background","`","and","`","composite","`","are","images",",","while","`","layers","`","is","a","list","of","images",".","The","images","are","of","type","PIL.Image",",","np.array",",","or","str","filepath",",","depending","on","the","`","type","`","parameter",".","Postprocessing",":","expects","a","dictionary","with","keys",":","`","background","`",",","`","layers","`",",","and","`","composite","`",".","The","values","corresponding","to","`","background","`","and","`","composite","`","should","be","images","or","None",",","while","`","layers","`","should","be","a","list","of","images",".","Images","can","be","of","type","PIL.Image",",","np.array",",","or","str","filepath\/URL",".","Or",",","the","value","can","be","simply","a","single","image",",","in","which","case","it","will","be","used","as","the","background",".","Examples-format",":","a","dictionary","with","keys",":","`","background","`",",","`","layers","`",",","and","`","composite","`",".","The","values","corresponding","to","`","background","`","and","`","composite","`","should","be","strings","or","None",",","while","`","layers","`","should","be","a","list","of","strings",".","The","image","corresponding","to","`","composite","`",",","if","not","None",",","is","used","as","the","example","image",".","Otherwise",",","the","image","corresonding","to","`","background","`","is","used",".","The","strings","should","be","filepaths","or","URLs",".","Or",",","the","value","can","be","simply","a","single","string","filepath\/URL","to","an","image",",","which","is","used","directly","as","the","example","image",".","Demos",":","image_editor"]
code: def postprocess(
      self, value: EditorValue | ImageType | None
  ) -> EditorData | None:
      if value is None:
          return None
      elif isinstance(value, dict):
          pass
      elif isinstance(value, (np.ndarray, _Image.Image, str)):
          value = {
              "background": value,
              "layers": [],
              "composite": value,
          }
      else:
          raise ValueError(
              "The value to `gr.ImageEditor` must be a dictionary of images or a single image."
          )
  
      layers = (
          [
              FileData(
                  path=image_utils.save_image(
                      cast(Union[np.ndarray, _Image.Image, str], layer),
                      self.GRADIO_CACHE,
                  )
              )
              for layer in value["layers"]
          ]
          if value["layers"]
          else []
      )
  
      return EditorData(
          background=FileData(
              path=image_utils.save_image(
                  value["background"], self.GRADIO_CACHE
              )
          )
          if value["background"] is not None
          else None,
          layers=layers,
          composite=FileData(
              path=image_utils.save_image(
                  cast(
                      Union[np.ndarray, _Image.Image, str],
                      value["composite"],
                  ),
                  self.GRADIO_CACHE,
              )
          )
          if value["composite"] is not None
          else None,
      )
  
imports: from __future__ import annotations
  import dataclasses
  import warnings
  from pathlib import Path
  from typing import Any, Iterable, List, Literal, Optional, TypedDict, Union, cast
  import numpy
  from gradio_client.documentation import document, set_documentation_group
  from PIL import Image
  import gradio.image_utils
  from gradio import utils
  from gradio.components.base import Component
  from gradio.data_classes import FileData, GradioModel
  from gradio.events import Events
label_desc: Use image node_id 4 for calling the ImageEditor obj's underlying member method code with example usage: obj.postprocess(value) and returns: EditorData, None