code: def train(
      model: GraphGymModule,
      datamodule: GraphGymDataModule,
      logger: bool = True,
      trainer_config: Optional[Dict[str, Any]] = None,
  ):
      r"""Trains a GraphGym model using PyTorch Lightning.
  
      Args:
          model (GraphGymModule): The GraphGym model.
          datamodule (GraphGymDataModule): The GraphGym data module.
          logger (bool, optional): Whether to enable logging during training.
              (default: :obj:`True`)
          trainer_config (dict, optional): Additional trainer configuration.
      """
      warnings.filterwarnings(
          "ignore", ".*use `CSVLogger` as the default.*"
      )
  
      callbacks = []
      if logger:
          callbacks.append(LoggerCallback())
      if cfg.train.enable_ckpt:
          ckpt_cbk = pl.callbacks.ModelCheckpoint(
              dirpath=get_ckpt_dir()
          )
          callbacks.append(ckpt_cbk)
  
      trainer_config = trainer_config or {}
      trainer = pl.Trainer(
          **trainer_config,
          enable_checkpointing=cfg.train.enable_ckpt,
          callbacks=callbacks,
          default_root_dir=cfg.out_dir,
          max_epochs=cfg.optim.max_epoch,
          accelerator=cfg.accelerator,
          devices="auto"
          if not torch.cuda.is_available()
          else cfg.devices,
      )
  
      trainer.fit(model, datamodule=datamodule)
      trainer.test(model, datamodule=datamodule)
  
file_path: pytorch_geometric/torch_geometric/graphgym/train.py
imports: import warnings
  from typing import Any, Dict, Optional
  import torch
  from torch.utils.data import DataLoader
  from torch_geometric.data.lightning.datamodule import LightningDataModule
  from torch_geometric.graphgym import create_loader
  from torch_geometric.graphgym.checkpoint import get_ckpt_dir
  from torch_geometric.graphgym.config import cfg
  from torch_geometric.graphgym.imports import pl
  from torch_geometric.graphgym.logger import LoggerCallback
  from torch_geometric.graphgym.model_builder import GraphGymModule
label_desc: Use image node_id 1 for calling a global function with example usage: train(model, datamodule, logger, trainer_config) without return types