code: def groupby(
      cls, dataset, dimensions, container_type, group_type, **kwargs
  ):
      # aggregate the necessary dimensions
      index_dims = [
          dataset.get_dimension(d, strict=True) for d in dimensions
      ]
      element_dims = [
          kdim for kdim in dataset.kdims if kdim not in index_dims
      ]
  
      group_kwargs = {}
      if group_type != "raw" and issubclass(group_type, Element):
          group_kwargs = dict(
              util.get_param_values(dataset), kdims=element_dims
          )
      group_kwargs.update(kwargs)
      group_kwargs["dataset"] = dataset.dataset
  
      group_by = [d.name for d in index_dims]
  
      # execute a query against the table to find the unique groups.
      if ibis4():
          groups = dataset.data.group_by(group_by).aggregate().execute()
      else:
          # groupby will be removed in Ibis 5.0
          groups = dataset.data.groupby(group_by).aggregate().execute()
  
      # filter each group based on the predicate defined.
      data = [
          (
              tuple(s.values.tolist()),
              group_type(
                  dataset.data.filter(
                      [
                          dataset.data[k] == v
                          for k, v in s.to_dict().items()
                      ]
                  ),
                  **group_kwargs,
              ),
          )
          for i, s in groups.iterrows()
      ]
      if issubclass(container_type, NdMapping):
          with item_check(False), sorted_context(False):
              return container_type(data, kdims=index_dims)
      else:
          return container_type(data)
  
imports: import sys
  from collections.abc import Iterable
  from functools import lru_cache
  import numpy
  from packaging.version import Version
  from ..None import util
  from ..element import Element
  from ..ndmapping import NdMapping, item_check, sorted_context
  from .None import pandas
  from .interface import Interface
  from .util import cached
label_desc: Use image node_id 20 for calling the IbisInterface obj's underlying member method code with example usage: obj.groupby(cls, dataset, dimensions, container_type, group_type) and returns: container_type, container_type