code: def train_model(model, dataloader, opt, feat, y):
      times_d = {
          key: 0
          for key in ["mfg_creation", "feature", "m_fwd", "m_bkwd"]
      }
      epoch_st = time.time()
      mfg_st = time.time()
      for input_nodes, output_nodes, blocks in dataloader:
          times_d["mfg_creation"] += time.time() - mfg_st
          if feat is not None:
              fst = time.time()
              input_nodes = input_nodes.to("cpu")
              input_feat = feat[input_nodes]
              input_feat = input_feat.to("cuda")
              if isinstance(output_nodes, dict):
                  output_nodes = output_nodes["paper"]
              output_nodes = output_nodes.to(y.device)
              y_batch = y[output_nodes].to("cuda")
              times_d["feature"] += time.time() - fst
  
              m_fwd_st = time.time()
              y_hat = model(blocks, input_feat)
              times_d["m_fwd"] += time.time() - m_fwd_st
  
              m_bkwd_st = time.time()
              loss = F.cross_entropy(y_hat, y_batch)
              opt.zero_grad()
              loss.backward()
              opt.step()
              times_d["m_bkwd"] += time.time() - m_bkwd_st
          mfg_st = time.time()
  
      print(f"Epoch time = {time.time() - epoch_st:.2f} seconds")
      print(
          f"Time to create MFG = {times_d['mfg_creation']:.2f} seconds"
      )
  
      return times_d
  
file_path: cugraph/benchmarks/cugraph-dgl/scale-benchmarks/model.py
imports: import torch
  import torch.nn.functional
  import time
label_desc: Use image node_id 2 for calling a global function with example usage: train_model(model, dataloader, opt, feat, y) and returns: times_d