class_docstr: Interface for 2 or 3D arrays representing images
  of raw luminance values, RGB values or HSV values.
class_docstr_tok: ["Interface","for","2","or","3D","arrays","representing","images","of","raw","luminance","values",",","RGB","values","or","HSV","values","."]
code: def groupby(
      cls, dataset, dim_names, container_type, group_type, **kwargs
  ):
      # Get dimensions information
      dimensions = [dataset.get_dimension(d) for d in dim_names]
      kdims = [kdim for kdim in dataset.kdims if kdim not in dimensions]
  
      # Update the kwargs appropriately for Element group types
      group_kwargs = {}
      group_type = dict if group_type == "raw" else group_type
      if issubclass(group_type, Element):
          group_kwargs.update(util.get_param_values(dataset))
          group_kwargs["kdims"] = kdims
      group_kwargs.update(kwargs)
  
      if len(dimensions) == 1:
          didx = dataset.get_dimension_index(dimensions[0])
          coords = dataset.dimension_values(
              dimensions[0], expanded=False
          )
          xvals = dataset.dimension_values(
              abs(didx - 1), expanded=False
          )
          samples = [
              (i, slice(None)) if didx else (slice(None), i)
              for i in range(dataset.data.shape[abs(didx - 1)])
          ]
          data = np.flipud(dataset.data)
          groups = [
              (c, group_type((xvals, data[s]), **group_kwargs))
              for s, c in zip(samples, coords)
          ]
      else:
          data = zip(
              *[
                  dataset.dimension_values(i)
                  for i in range(len(dataset.dimensions()))
              ]
          )
          groups = [
              (
                  g[: dataset.ndims],
                  group_type([g[dataset.ndims :]], **group_kwargs),
              )
              for g in data
          ]
  
      if issubclass(container_type, NdMapping):
          with item_check(False):
              return container_type(groups, kdims=dimensions)
      else:
          return container_type(groups)
  
imports: import numpy
  from ..None import util
  from ..boundingregion import BoundingBox
  from ..dimension import dimension_name
  from ..element import Element
  from ..ndmapping import NdMapping, item_check
  from ..sheetcoords import SheetCoordinateSystem, Slice
  from .grid import GridInterface
  from .interface import DataError, Interface
  from .util import finite_range
label_desc: Use image node_id 15 for calling the ImageInterface obj's underlying member method code with example usage: obj.groupby(cls, dataset, dim_names, container_type, group_type) and returns: container_type, container_type