code: def main(args):
      if os.path.exists(args.save_dataset):
          train_dataset, valid_dataset, test_dataset = pickle.load(
              open(args.save_dataset, "rb")
          )
      else:
          train_dataset, valid_dataset, test_dataset = get_datasets(
              args.fnames, device=args.device, save=args.save_dataset
          )
      args = vocab_config(
          args,
          train_dataset.ent_vocab,
          train_dataset.rel_vocab,
          train_dataset.text_vocab,
          train_dataset.ent_text_vocab,
          train_dataset.title_vocab,
      )
      train_dataloader = torch.utils.data.DataLoader(
          train_dataset,
          batch_sampler=BucketSampler(
              train_dataset, batch_size=args.batch_size
          ),
          collate_fn=train_dataset.batch_fn,
      )
      valid_dataloader = torch.utils.data.DataLoader(
          valid_dataset,
          batch_size=args.batch_size,
          shuffle=False,
          collate_fn=train_dataset.batch_fn,
      )
      test_dataloader = torch.utils.data.DataLoader(
          test_dataset,
          batch_size=args.batch_size,
          shuffle=False,
          collate_fn=train_dataset.batch_fn,
      )
  
      model = GraphWriter(args)
      model.to(args.device)
      if args.test:
          model = torch.load(args.save_model)
          model.args = args
          print(model)
          test(model, test_dataloader, args)
      else:
          optimizer = torch.optim.SGD(
              model.parameters(),
              lr=args.lr,
              weight_decay=args.weight_decay,
              momentum=0.9,
          )
          print(model)
          for epoch in range(args.epoch):
              train_one_epoch(
                  model, train_dataloader, optimizer, args, epoch
              )
              eval_it(model, valid_dataloader, args, epoch)
  
file_path: dgl/examples/pytorch/graphwriter/train.py
imports: import os
  import sys
  import time
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from graphwriter import *
  from opts import *
  from tqdm import tqdm
  from utlis import *
  from pycocoevalcap.bleu.bleu import Bleu
  from pycocoevalcap.meteor.meteor import Meteor
  from pycocoevalcap.rouge.rouge import Rouge
label_desc: Use image node_id 4 for calling a global function with example usage: main(args) without return types