class_docstr: Format images for logging to W&B.
  
  Arguments:
      data_or_path: (numpy array, string, io) Accepts numpy array of
          image data, or a PIL image. The class attempts to infer
          the data format and converts it.
      mode: (string) The PIL mode for an image. Most common are "L", "RGB",
          "RGBA". Full explanation at https://pillow.readthedocs.io/en/stable/handbook/concepts.html#modes
      caption: (string) Label for display of image.
  
  Note : When logging a `torch.Tensor` as a `wandb.Image`, images are normalized. If you do not want to normalize your images, please convert your tensors to a PIL Image.
  
  Examples:
      ### Create a wandb.Image from a numpy array
      <!--yeadoc-test:log-image-numpy-->
      ```python
      import numpy as np
      import wandb
  
      with wandb.init() as run:
          examples = []
          for i in range(3):
              pixels = np.random.randint(low=0, high=256, size=(100, 100, 3))
              image = wandb.Image(pixels, caption=f"random field {i}")
              examples.append(image)
          run.log({"examples": examples})
      ```
  
      ### Create a wandb.Image from a PILImage
      <!--yeadoc-test:log-image-pillow-->
      ```python
      import numpy as np
      from PIL import Image as PILImage
      import wandb
  
      with wandb.init() as run:
          examples = []
          for i in range(3):
              pixels = np.random.randint(low=0, high=256, size=(100, 100, 3), dtype=np.uint8)
              pil_image = PILImage.fromarray(pixels, mode="RGB")
              image = wandb.Image(pil_image, caption=f"random field {i}")
              examples.append(image)
          run.log({"examples": examples})
      ```
  
      ### log .jpg rather than .png (default)
      <!--yeadoc-test:log-image-format-->
      ```python
      import numpy as np
      import wandb
  
      with wandb.init() as run:
          examples = []
          for i in range(3):
              pixels = np.random.randint(low=0, high=256, size=(100, 100, 3))
              image = wandb.Image(pixels, caption=f"random field {i}", file_type="jpg")
              examples.append(image)
          run.log({"examples": examples})
      ```
class_docstr_tok: ["Format","images","for","logging","to","W","&","B",".","Arguments",":","data_or_path",":","(","numpy","array",",","string",",","io",")","Accepts","numpy","array","of","image","data",",","or","a","PIL","image",".","The","class","attempts","to","infer","the","data","format","and","converts","it",".","mode",":","(","string",")","The","PIL","mode","for","an","image",".","Most","common","are","``","L","''",",","``","RGB","''",",","``","RGBA","''",".","Full","explanation","at","https",":","\/\/pillow.readthedocs.io\/en\/stable\/handbook\/concepts.html","#","modes","caption",":","(","string",")","Label","for","display","of","image",".","Note",":","When","logging","a","`","torch.Tensor","`","as","a","`","wandb.Image","`",",","images","are","normalized",".","If","you","do","not","want","to","normalize","your","images",",","please","convert","your","tensors","to","a","PIL","Image",".","Examples",":","#","#","#","Create","a","wandb.Image","from","a","numpy","array","<","!","--","yeadoc-test",":","log-image-numpy","--",">","``","`","python","import","numpy","as","np","import","wandb","with","wandb.init","(",")","as","run",":","examples","=","[","]","for","i","in","range","(","3",")",":","pixels","=","np.random.randint","(","low=0",",","high=256",",","size=","(","100",",","100",",","3",")",")","image","=","wandb.Image","(","pixels",",","caption=f","''","random","field","{","i","}","''",")","examples.append","(","image",")","run.log","(","{","``","examples","''",":","examples","}",")","``","`","#","#","#","Create","a","wandb.Image","from","a","PILImage","<","!","--","yeadoc-test",":","log-image-pillow","--",">","``","`","python","import","numpy","as","np","from","PIL","import","Image","as","PILImage","import","wandb","with","wandb.init","(",")","as","run",":","examples","=","[","]","for","i","in","range","(","3",")",":","pixels","=","np.random.randint","(","low=0",",","high=256",",","size=","(","100",",","100",",","3",")",",","dtype=np.uint8",")","pil_image","=","PILImage.fromarray","(","pixels",",","mode=","''","RGB","''",")","image","=","wandb.Image","(","pil_image",",","caption=f","''","random","field","{","i","}","''",")","examples.append","(","image",")","run.log","(","{","``","examples","''",":","examples","}",")","``","`","#","#","#","log",".jpg","rather","than",".png","(","default",")","<","!","--","yeadoc-test",":","log-image-format","--",">","``","`","python","import","numpy","as","np","import","wandb","with","wandb.init","(",")","as","run",":","examples","=","[","]","for","i","in","range","(","3",")",":","pixels","=","np.random.randint","(","low=0",",","high=256",",","size=","(","100",",","100",",","3",")",")","image","=","wandb.Image","(","pixels",",","caption=f","''","random","field","{","i","}","''",",","file_type=","''","jpg","''",")","examples.append","(","image",")","run.log","(","{","``","examples","''",":","examples","}",")","``","`"]
docstr: Guess what type of image the np.array is representing.
docstr_tok: ["Guess","what","type","of","image","the","np.array","is","representing","."]
code: def guess_mode(self, data: "np.ndarray") -> str:
      """Guess what type of image the np.array is representing."""
      # TODO: do we want to support dimensions being at the beginning of the array?
      if data.ndim == 2:
          return "L"
      elif data.shape[-1] == 3:
          return "RGB"
      elif data.shape[-1] == 4:
          return "RGBA"
      else:
          raise ValueError(
              "Un-supported shape for image conversion %s"
              % list(data.shape)
          )
  
imports: import hashlib
  import logging
  import os
  from io import BytesIO
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Type, Union, cast
  from urllib import parse
  import wandb
  from wandb import util
  from wandb.sdk.lib import hashutil, runid
  from wandb.sdk.lib.paths import LogicalPath
  from ._private import MEDIA_TMP
  from .base_types.media import BatchableMedia, Media
  from .helper_types.bounding_boxes_2d import BoundingBoxes2D
  from .helper_types.classes import Classes
  from .helper_types.image_mask import ImageMask
label_desc: Use image node_id 11 for calling the Image obj's underlying member method code with example usage: obj.guess_mode(data) and returns: str, str, str