def update(self, res, *, stream=None):
        """Update the metrics.

        :param res: a dictionary of new metrics with <metric_name: value> items.
        :param stream: optional stream. If a stream is given the full metric
            name becomes `f'{stream.name}/{metric_name}'`.
        """
        for k, v in res.items():
            # optional safety check on metric shape
            # metrics are expected to have one value for each experience in the stream
            if stream is not None:
                if stream.name not in self._stream_len:
                    self._init_stream(stream)
                if len(v) != self._stream_len[stream.name]:
                    raise ValueError(
                        f"Length does not correspond to stream. "
                        f"Found {len(v)}, expected {self._stream_len[stream.name]}"
                    )

            # update metrics dictionary
            if stream is not None:
                k = f"{stream.name}/{k}"
            if k in self.metrics_res:
                self.metrics_res[k].append(v)
            else:
                self.metrics_res[k] = [v]
Update the metrics.

        :param res: a dictionary of new metrics with <metric_name: value> items.
        :param stream: optional stream. If a stream is given the full metric
            name becomes `f'{stream.name}/{metric_name}'`.
        
avalanche/evaluation/collector.py