def test_multiple_loggers_pickle(tmp_path):
    """Verify that pickling trainer with multiple loggers works."""
    logger1 = CustomLogger()
    logger2 = CustomLogger()

    trainer = Trainer(logger=[logger1, logger2])
    pkl_bytes = pickle.dumps(trainer)
    trainer2 = pickle.loads(pkl_bytes)
    for logger in trainer2.loggers:
        logger.log_metrics({"acc": 1.0}, 0)

    for logger in trainer2.loggers:
        assert logger.metrics_logged == {"acc": 1.0}
Verify that pickling trainer with multiple loggers works.
tests/tests_pytorch/loggers/test_logger.py