class_docstr: ImageStack expands the capabilities of Image to by supporting
  multiple layers of images.
  
  As there is many ways to represent multiple layers of images,
  the following options are supported:
  
      1) A 3D Numpy array with the shape (y, x, level)
      2) A list of 2D Numpy arrays with identical shape (y, x)
      3) A dictionary where the keys will be set as the vdims and the
          values are 2D Numpy arrays with identical shapes (y, x).
          If the dictionary's keys matches the kdims of the element,
          they need to be 1D arrays.
      4) A tuple containing (x, y, level_0, level_1, ...),
          where the level is a 2D Numpy array in the shape of (y, x).
      5) An xarray DataArray or Dataset where its `coords` contain the kdims.
  
  If no kdims are supplied, x and y are used.
  
  If no vdims are supplied, and the naming can be inferred like with a dictionary
  the levels will be named level_0, level_1, etc.
class_docstr_tok: ["ImageStack","expands","the","capabilities","of","Image","to","by","supporting","multiple","layers","of","images",".","As","there","is","many","ways","to","represent","multiple","layers","of","images",",","the","following","options","are","supported",":","1",")","A","3D","Numpy","array","with","the","shape","(","y",",","x",",","level",")","2",")","A","list","of","2D","Numpy","arrays","with","identical","shape","(","y",",","x",")","3",")","A","dictionary","where","the","keys","will","be","set","as","the","vdims","and","the","values","are","2D","Numpy","arrays","with","identical","shapes","(","y",",","x",")",".","If","the","dictionary","'s","keys","matches","the","kdims","of","the","element",",","they","need","to","be","1D","arrays",".","4",")","A","tuple","containing","(","x",",","y",",","level_0",",","level_1",",","...",")",",","where","the","level","is","a","2D","Numpy","array","in","the","shape","of","(","y",",","x",")",".","5",")","An","xarray","DataArray","or","Dataset","where","its","`","coords","`","contain","the","kdims",".","If","no","kdims","are","supplied",",","x","and","y","are","used",".","If","no","vdims","are","supplied",",","and","the","naming","can","be","inferred","like","with","a","dictionary","the","levels","will","be","named","level_0",",","level_1",",","etc","."]
code: def __init__(self, data, kdims=None, vdims=None, **params):
      _kdims = kdims or self.kdims
      if isinstance(data, list) and len(data):
          x = np.arange(data[0].shape[1])
          y = np.arange(data[0].shape[0])
          data = (x, y, *data)
      elif isinstance(data, dict):
          first = next(v for k, v in data.items() if k not in _kdims)
          xdim, ydim = map(str, _kdims)
          if xdim not in data:
              data[xdim] = np.arange(first.shape[1])
          if ydim not in data:
              data[ydim] = np.arange(first.shape[0])
      elif isinstance(data, np.ndarray) and data.ndim == 3:
          x = np.arange(data.shape[1])
          y = np.arange(data.shape[0])
          arr = (data[:, :, n] for n in range(data.shape[2]))
          data = (x, y, *arr)
      elif (
          isinstance(data, tuple)
          and len(data) == 3
          and isinstance(data[2], np.ndarray)
          and data[2].ndim == 3
      ):
          arr = (data[2][:, :, n] for n in range(data[2].shape[2]))
          data = (data[0], data[1], *arr)
  
      if vdims is None:
          if isinstance(data, tuple):
              vdims = [
                  Dimension(f"level_{i}") for i in range(len(data[2:]))
              ]
          elif isinstance(data, dict):
              vdims = [
                  Dimension(key)
                  for key in data.keys()
                  if key not in _kdims
              ]
      super().__init__(data, kdims=kdims, vdims=vdims, **params)
  
imports: import colorsys
  from copy import deepcopy
  from operator import itemgetter
  import numpy
  import param
  from ..core import Dataset, Dimension, Element2D, Overlay, config, util
  from ..core.boundingregion import BoundingBox, BoundingRegion
  from ..core.data import ImageInterface
  from ..core.data.interface import DataError
  from ..core.dimension import dimension_name
  from ..core.sheetcoords import SheetCoordinateSystem, Slice
  from .chart import Curve
  from .geom import Selection2DExpr
  from .graphs import TriMesh
  from .tabular import Table
  from .util import categorical_aggregate2d, compute_slice_bounds
label_desc: Use image node_id 1 to create a new ImageStack object from inherited base classes: Image with example: obj = ImageStack(data, kdims, vdims)