code: def training_loop(self):
      # You can access any Trainer attributes directly in this method.
      # self.datasets["train"] has already been
      # preprocessed by self.preprocessor
      dataset = self.datasets["train"]
  
      loss_fn = torch.nn.MSELoss()
  
      for epoch_idx in range(10):
          loss = 0
          num_batches = 0
          for batch in dataset.iter_torch_batches(dtypes=torch.float):
              # Compute prediction error
              X, y = torch.unsqueeze(batch["x"], 1), batch["y"]
              pred = self.model(X)
              batch_loss = loss_fn(pred, y)
  
              # Backpropagation
              self.optimizer.zero_grad()
              batch_loss.backward()
              self.optimizer.step()
  
              loss += batch_loss.item()
              num_batches += 1
          loss /= num_batches
  
          # Use Tune functions to report intermediate
          # results.
          train.report({"loss": loss, "epoch": epoch_idx})
  
file_path: ray/python/ray/air/examples/custom_trainer.py
imports: import torch
  from ray import train
  from ray.train.trainer import BaseTrainer
  import ray
label_desc: Use image node_id 2 for calling the MyPytorchTrainer obj's underlying member method code with example usage: obj.training_loop() without return types