code: def _aggregate_metrics(self, session_group):
      
  
      if (self._request.aggregation_type == api_pb2.AGGREGATION_AVG or
          self._request.aggregation_type == api_pb2.AGGREGATION_UNSET):
        _set_avg_session_metrics(session_group)
      elif self._request.aggregation_type == api_pb2.AGGREGATION_MEDIAN:
        _set_median_session_metrics(session_group,
                                    self._request.aggregation_metric)
      elif self._request.aggregation_type == api_pb2.AGGREGATION_MIN:
        _set_extremum_session_metrics(session_group,
                                      self._request.aggregation_metric,
                                      min)
      elif self._request.aggregation_type == api_pb2.AGGREGATION_MAX:
        _set_extremum_session_metrics(session_group,
                                      self._request.aggregation_metric,
                                      max)
      else:
        raise error.HParamsError('Unknown aggregation_type in request: %s' %
                                 self._request.aggregation_type)
docs: Sets the metrics of the group based on aggregation_type.