code: def test_first_logger_call_in_subprocess(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)
  
imports: import os
  from typing import Any, Dict, Optional, Union
  from unittest.mock import Mock
  import lightning.pytorch
  from lightning.pytorch import Callback, Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.loggers.logger import Logger
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 3 for calling a global function with example usage: test_first_logger_call_in_subprocess(tmpdir) without return types