code: def _check_aggfunc(aggfunc, weighted=False):
      _weighted = "weighted" if weighted else "unweighted"
      if aggfunc not in VALID_AGG_FUNCS.keys():
          raise ValueError(
              "Aggregation function %s not recognized." % aggfunc
          )
      return VALID_AGG_FUNCS[aggfunc][_weighted]
  
imports: import numpy
  import pandas
  from scipy.stats import gmean
  from sklearn.pipeline import Pipeline
  from sktime.forecasting.base import ForecastingHorizon
  from sktime.forecasting.base._meta import _HeterogenousEnsembleForecaster
  from sktime.split import temporal_train_test_split
  from sktime.utils.stats import _weighted_geometric_mean, _weighted_max, _weighted_median, _weighted_min
  from sktime.utils.validation.forecasting import check_regressor
label_desc: Use image node_id 3 for calling a global function with example usage: _check_aggfunc(aggfunc, weighted) and returns: VALID_AGG_FUNCS