def get(
        self, name, *, time_reduce=None, exp_reduce=None, stream=None, weights=None
    ):
        """Returns a metric value given its name and aggregation method.

        :param name: name of the metric.
        :param time_reduce: Aggregation over the time dimension. One of {None, 'last', 'mean'}, where:
            - None (default) does not use any aggregation
            - 'last' returns the last timestep
            - 'mean' averages over time
        :param exp_reduce: Aggregation over the experience dimension. One of {None, 'sample_mean', 'experience_mean'} where:
            - None (default) does not use any aggregation
            - `sample_mean` is an average weighted by the number of samples in each experience
            - `experience_mean` is an experience average.
            - 'weighted_sum' is a weighted sum of the experiences using the `weights` argument.
        :param stream: stream that was used to compute the metric. This is
            needed to build the full metric name if the get was called with a
            stream name and if `exp_reduce == sample_mean` to get the number
            of samples from each experience.
        :param weights: weights for each experience when `exp_reduce == 'weighted_sum`.
        :return: aggregated metric value.
        """
        assert time_reduce in {None, "last", "mean"}
        assert exp_reduce in {None, "sample_mean", "experience_mean", "weighted_sum"}
        if exp_reduce == "weighted_sum":
            assert (
                weights is not None
            ), "You should set the `weights` argument when `exp_reduce == 'weighted_sum'`."
        else:
            assert (
                weights is None
            ), "Can't use the `weights` argument when `exp_reduce != 'weighted_sum'`"

        if stream is not None:
            name = f"{stream.name}/{name}"
        if name not in self.metrics_res:
            print(
                f"{name} metric was not found. Maybe you forgot the `stream` argument?"
            )

        mvals = np.array(self.metrics_res[name])
        if exp_reduce is None:
            pass  # nothing to do here
        elif exp_reduce == "sample_mean":
            if stream is None:
                raise ValueError(
                    "If you want to use `exp_reduce == sample_mean` you need to provide"
                    "the `stream` argument to the `update` and `get` methods."
                )
            if stream.name not in self._coeffs:
                self._init_stream(stream)
            mvals = mvals * self._coeffs[stream.name][None, :]  # weight by num.samples
            mvals = mvals.sum(axis=1)  # weighted avg across exp.
        elif exp_reduce == "experience_mean":
            mvals = mvals.mean(axis=1)  # avg across exp.
        elif exp_reduce == "weighted_sum":
            weights = np.array(weights)[None, :]
            mvals = (mvals * weights).sum(axis=1)
        else:
            raise ValueError("BUG. It should never get here.")

        if time_reduce is None:
            pass  # nothing to do here
        elif time_reduce == "last":
            mvals = mvals[-1]  # last timestep
        elif time_reduce == "mean":
            mvals = mvals.mean(axis=0)  # avg. over time
        else:
            raise ValueError("BUG. It should never get here.")

        return mvals
Returns a metric value given its name and aggregation method.

        :param name: name of the metric.
        :param time_reduce: Aggregation over the time dimension. One of {None, 'last', 'mean'}, where:
            - None (default) does not use any aggregation
            - 'last' returns the last timestep
            - 'mean' averages over time
        :param exp_reduce: Aggregation over the experience dimension. One of {None, 'sample_mean', 'experience_mean'} where:
            - None (default) does not use any aggregation
            - `sample_mean` is an average weighted by the number of samples in each experience
            - `experience_mean` is an experience average.
            - 'weighted_sum' is a weighted sum of the experiences using the `weights` argument.
        :param stream: stream that was used to compute the metric. This is
            needed to build the full metric name if the get was called with a
            stream name and if `exp_reduce == sample_mean` to get the number
            of samples from each experience.
        :param weights: weights for each experience when `exp_reduce == 'weighted_sum`.
        :return: aggregated metric value.
        
avalanche/evaluation/collector.py