code: def train(state):
      # post synchronization event (worker added, worker removed) init ...
      for state.epoch in range(state.epoch, args.epochs + 1):
          state.model.train()
  
          train_sampler.set_epoch(state.epoch)
          steps_remaining = len(train_loader) - state.batch
  
          for state.batch, (data, target) in enumerate(train_loader):
              if state.batch >= steps_remaining:
                  break
  
              if args.cuda:
                  data, target = data.cuda(), target.cuda()
              state.optimizer.zero_grad()
              output = state.model(data)
              loss = F.nll_loss(output, target)
              loss.backward()
              state.optimizer.step()
              if state.batch % args.log_interval == 0:
                  # Horovod: use train_sampler to determine the number of examples in
                  # this worker's partition.
                  print(
                      "Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}".format(
                          state.epoch,
                          state.batch * len(data),
                          len(train_sampler),
                          100.0 * state.batch / len(train_loader),
                          loss.item(),
                      )
                  )
              state.commit()
          state.batch = 0
  
file_path: horovod/examples/elastic/pytorch/pytorch_mnist_elastic.py
imports: import argparse
  import os
  from filelock import FileLock
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from torchvision import datasets, transforms
  import torch.utils.data.distributed
  import horovod.torch
label_desc: Use image node_id 2 for calling a global function with example usage: train(state) without return types