class_docstr: ## Configurations
class_docstr_tok: ["#","#","Configurations"]
docstr: ### Train
docstr_tok: ["#","#","#","Train"]
code: def train(self):
      """
      ### Train
      """
  
      # Iterate through the dataset
      for data in monit.iterate("Train", self.data_loader):
          # Increment global step
          tracker.add_global_step()
          # Move data to device
          data = data.to(self.device)
  
          # Make the gradients zero
          self.optimizer.zero_grad()
          # Calculate loss
          loss = self.diffusion.loss(data)
          # Compute gradients
          loss.backward()
          # Take an optimization step
          self.optimizer.step()
          # Track the loss
          tracker.save("loss", loss)
  
imports: from typing import List
  import torch
  import torch.utils.data
  import torchvision
  from PIL import Image
  from labml import lab, tracker, experiment, monit
  from labml.configs import BaseConfigs, option
  from labml_helpers.device import DeviceConfigs
  from labml_nn.diffusion.ddpm import DenoiseDiffusion
  from labml_nn.diffusion.ddpm.unet import UNet
label_desc: Use image node_id 3 for calling the Configs obj's underlying member method code with example usage: obj.train() without return types