code: def aggregate(cls, dataset, dimensions, function, **kwargs):
      import ibis.expr.operations
  
      data = dataset.data
      columns = [d.name for d in dataset.kdims if d in dimensions]
      values = dataset.dimensions("value", label="name")
      new = data[columns + values]
  
      function = {
          np.min: ibis.expr.operations.Min,
          np.nanmin: ibis.expr.operations.Min,
          np.max: ibis.expr.operations.Max,
          np.nanmax: ibis.expr.operations.Max,
          np.mean: ibis.expr.operations.Mean,
          np.nanmean: ibis.expr.operations.Mean,
          np.std: ibis.expr.operations.StandardDev,
          np.nanstd: ibis.expr.operations.StandardDev,
          np.sum: ibis.expr.operations.Sum,
          np.nansum: ibis.expr.operations.Sum,
          np.var: ibis.expr.operations.Variance,
          np.nanvar: ibis.expr.operations.Variance,
          len: ibis.expr.operations.Count,
      }.get(function, function)
  
      if len(dimensions):
          if ibis4():
              selection = new.group_by(columns)
          else:
              # groupby will be removed in Ibis 5.0
              selection = new.groupby(columns)
  
          if function is np.count_nonzero:
              aggregation = selection.aggregate(
                  **{
                      x: ibis.expr.operations.Count(
                          new[x], where=new[x] != 0
                      ).to_expr()
                      for x in new.columns
                      if x not in columns
                  }
              )
          else:
              aggregation = selection.aggregate(
                  **{
                      x: function(new[x]).to_expr()
                      for x in new.columns
                      if x not in columns
                  }
              )
      else:
          aggregation = new.aggregate(
              **{x: function(new[x]).to_expr() for x in new.columns}
          )
  
      dropped = [x for x in values if x not in data.columns]
      return aggregation, dropped
  
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 27 for calling the IbisInterface obj's underlying member method code with example usage: obj.aggregate(cls, dataset, dimensions, function) and returns: aggregation,  dropped