    def __init__(
        self,
        model,
        config: EMAModuleConfig,
        copy_model=True,
        device=None,
        skip_keys=None,
    ):
        """
        @param model model to initialize the EMA with
        @param config EMAConfig object with configuration like
        ema_decay, ema_update_freq, ema_fp32
        @param device If provided, copy EMA to this device (e.g. gpu).
        Otherwise EMA is in the same device as the model.
        """

        self.config = config

        if copy_model:
            self.model = copy.deepcopy(model)
            self.model.requires_grad_(False)
        else:
            self.model = model

        self.config = config
        self.decay = config.ema_decay
        self.skip_keys = skip_keys or set()
        self.add_missing_params = config.add_missing_params
        self.fp32_params = {}

        if device is not None:
            logging.info(f"Copying EMA model to device {device}")
            self.model = self.model.to(device=device)

        if self.config.ema_fp32:
            self.build_fp32_params()

        self.log_norms = config.log_norms and multi_tensor_l2norm_available
        self.logs = {}
@param model model to initialize the EMA with
@param config EMAConfig object with configuration like
ema_decay, ema_update_freq, ema_fp32
@param device If provided, copy EMA to this device (e.g. gpu).
Otherwise EMA is in the same device as the model.
fairseq/modules/ema_module.py