def avg_func(self, averaged_param: torch.Tensor,
                 source_param: torch.Tensor, steps: int) -> None:
        """Compute the moving average of the parameters using the cosine
        momentum strategy.

        Args:
            averaged_param (Tensor): The averaged parameters.
            source_param (Tensor): The source parameters.
            steps (int): The number of times the parameters have been
                updated.

        Returns:
            Tensor: The averaged parameters.
        """
        message_hub = MessageHub.get_current_instance()
        max_iters = message_hub.get_info('max_iters')
        cosine_annealing = (cos(pi * steps / float(max_iters)) + 1) / 2
        momentum = self.end_momentum - (self.end_momentum -
                                        self.momentum) * cosine_annealing
        averaged_param.mul_(1 - momentum).add_(source_param, alpha=momentum)
Compute the moving average of the parameters using the cosine
        momentum strategy.

        Args:
            averaged_param (Tensor): The averaged parameters.
            source_param (Tensor): The source parameters.
            steps (int): The number of times the parameters have been
                updated.

        Returns:
            Tensor: The averaged parameters.
        
mmpretrain/models/utils/ema.py