code: def groupby(
      cls, dataset, dimensions, container_type, group_type, **kwargs
  ):
      data = dataset.data
  
      # Get dimension objects, labels, indexes and data
      dimensions = [
          dataset.get_dimension(d, strict=True) for d in dimensions
      ]
      dim_idxs = [dataset.get_dimension_index(d) for d in dimensions]
      kdims = [kdim for kdim in dataset.kdims if kdim not in dimensions]
      vdims = dataset.vdims
  
      # Find unique entries along supplied dimensions
      # by creating a view that treats the selected
      # groupby keys as a single object.
      indices = data[:, dim_idxs].copy()
      group_shape = indices.dtype.itemsize * indices.shape[1]
      view = indices.view(np.dtype((np.void, group_shape)))
      _, idx = np.unique(view, return_index=True)
      idx.sort()
      unique_indices = indices[idx]
  
      # Get group
      group_kwargs = {}
      if group_type != "raw" and issubclass(group_type, Element):
          group_kwargs.update(util.get_param_values(dataset))
          group_kwargs["kdims"] = kdims
      group_kwargs.update(kwargs)
  
      # Iterate over the unique entries building masks
      # to apply the group selection
      grouped_data = []
      col_idxs = [
          dataset.get_dimension_index(d)
          for d in dataset.dimensions()
          if d not in dimensions
      ]
      for group in unique_indices:
          mask = np.logical_and.reduce(
              [
                  data[:, d_idx] == group[i]
                  for i, d_idx in enumerate(dim_idxs)
              ]
          )
          group_data = data[mask][:, col_idxs]
          if not group_type == "raw":
              if issubclass(group_type, dict):
                  group_data = {
                      d.name: group_data[:, i]
                      for i, d in enumerate(kdims + vdims)
                  }
              else:
                  group_data = group_type(group_data, **group_kwargs)
          grouped_data.append((tuple(group), group_data))
  
      if issubclass(container_type, NdMapping):
          with item_check(False), sorted_context(False):
              return container_type(grouped_data, kdims=dimensions)
      else:
          return container_type(grouped_data)
  
imports: import numpy
  from ..None import util
  from ..dimension import dimension_name
  from ..element import Element
  from ..ndmapping import NdMapping, item_check, sorted_context
  from .interface import DataError, Interface
label_desc: Use image node_id 12 for calling the ArrayInterface obj's underlying member method code with example usage: obj.groupby(cls, dataset, dimensions, container_type, group_type) and returns: container_type, container_type