def aggregate(self, aggregations, _mongo=False):
        """Aggregates one or more
        :class:`fiftyone.core.aggregations.Aggregation` instances.

        Note that it is best practice to group aggregations into a single call
        to :meth:`aggregate`, as this will be more efficient than performing
        multiple aggregations in series.

        Args:
            aggregations: an :class:`fiftyone.core.aggregations.Aggregation` or
                iterable of :class:`fiftyone.core.aggregations.Aggregation`
                instances

        Returns:
            Aggregation result(s) corresponding to the input aggregation(s).
            Returns a single result for a single aggregation, a list of results
            for multiple aggregations, or a generator for lazy aggregations
        """
        if not aggregations:
            return []

        scalar_result = isinstance(aggregations, foa.Aggregation)

        if scalar_result:
            aggregations = [aggregations]

        # Partition aggregations by type
        big_aggs, batch_aggs, facet_aggs, stream = self._parse_aggregations(
            aggregations, allow_big=True
        )

        # Placeholder to store results
        results = [None] * len(aggregations)

        idx_map = {}
        pipelines = []

        # Build batch pipeline
        if batch_aggs:
            pipeline = self._build_batch_pipeline(batch_aggs)
            pipelines.append(pipeline)

        # Build big pipelines
        for idx, aggregation in big_aggs.items():
            pipeline = self._build_big_pipeline(aggregation)
            idx_map[idx] = len(pipelines)
            pipelines.append(pipeline)

        # Build facet-able pipelines
        compiled_facet_aggs, facet_pipelines, _ = self._build_facets(
            facet_aggs
        )
        for idx, pipeline in facet_pipelines.items():
            idx_map[idx] = len(pipelines)
            pipelines.append(pipeline)

        if _mongo:
            return pipelines[0] if scalar_result else pipelines

        # Run all aggregations
        _results = foo.aggregate(
            self._dataset._sample_collection, pipelines, _stream=stream
        )

        # Parse batch results
        if batch_aggs:
            if stream:
                return self._iter_and_parse_agg_results(batch_aggs, _results)
            result = list(_results[0])
            for idx, aggregation in batch_aggs.items():
                results[idx] = self._parse_big_result(aggregation, result)

        # Parse big results
        if big_aggs and stream:
            return self._iter_and_parse_agg_results(big_aggs, _results)
        for idx, aggregation in big_aggs.items():
            result = list(_results[idx_map[idx]])
            results[idx] = self._parse_big_result(aggregation, result)

        # Parse facet-able results
        for idx, aggregation in compiled_facet_aggs.items():

            result = list(_results[idx_map[idx]])
            data = self._parse_faceted_result(aggregation, result)
            if (
                isinstance(aggregation, foa.FacetAggregations)
                and aggregation._compiled
            ):
                for idx, d in data.items():
                    results[idx] = d
            else:
                results[idx] = data
        return results[0] if scalar_result else results
Aggregates one or more
        :class:`fiftyone.core.aggregations.Aggregation` instances.

        Note that it is best practice to group aggregations into a single call
        to :meth:`aggregate`, as this will be more efficient than performing
        multiple aggregations in series.

        Args:
            aggregations: an :class:`fiftyone.core.aggregations.Aggregation` or
                iterable of :class:`fiftyone.core.aggregations.Aggregation`
                instances

        Returns:
            Aggregation result(s) corresponding to the input aggregation(s).
            Returns a single result for a single aggregation, a list of results
            for multiple aggregations, or a generator for lazy aggregations
        
fiftyone/core/collections.py