def METHOD_NAME(tmpdir):
    """Test that the Trainer does not call the logger too early.
    Only when the worker processes are initialized do we have access to the rank and know which one is the main process.
    """
    class LoggerCallsObserver(Callback):
        def setup(self, trainer, pl_module, stage):
            # this hook is executed after Strategy has setup the environment
            # logger should not write any logs until this point
            assert not trainer.logger.method_calls
            assert not os.listdir(trainer.logger.save_dir)
        def on_train_start(self, trainer, pl_module):
            assert trainer.logger.method_call
            trainer.logger.log_graph.assert_called_once()
    logger = Mock()
    logger.version = "0"
    logger.name = "name"
    logger.save_dir = tmpdir
    model = BoringModel()
    trainer = Trainer(
        default_root_dir=tmpdir,
        limit_train_batches=1,
        limit_val_batches=1,
        max_epochs=1,
        logger=logger,
        callbacks=[LoggerCallsObserver()],
    )
    trainer.fit(model)