    def set_optimizer(self, optimizer: Optimizer):
        """
        Set the optimizer to callback.

        Args:
            optimizer (`torch.optim.Optimizer`):
                The optimizer which callback can operate.
        """
        self.optimizer = optimizer
        for cb in self.callbacks:
            cb.set_optimizer(optimizer)
Set the optimizer to callback.

Args:
optimizer (`torch.optim.Optimizer`):
The optimizer which callback can operate.
towhee/trainer/callback.py