def load_state_dict(self, state_dict):
        """
        Load an optimizer state dict.
        In general we should prefer the configuration of the existing optimizer instance
        (e.g., learning rate) over that found in the state_dict. This allows us to
        resume training from a checkpoint using a new set of optimizer args.
        """
        if (
            'loss_scaler' in state_dict
            and self.scaler is not None
            and isinstance(state_dict['loss_scaler'], float)
        ):
            self.scaler.loss_scale = state_dict['loss_scaler']
        self.optimizer.load_state_dict(state_dict)

        Load an optimizer state dict.
        In general we should prefer the configuration of the existing optimizer instance
        (e.g., learning rate) over that found in the state_dict. This allows us to
        resume training from a checkpoint using a new set of optimizer args.
        
EVA-CLIP/rei/training/fp16.py