code: def train(
      self,
      data: TrainingData,
      iterations: int = 100,
      epochs: int = 1,
      num_samples: int = 0,
  ) -> None:
      d_in, d_out = (
          data.train_x.shape[1],
          data.train_y.shape[1] if len(data.train_y.shape) > 1 else 1,
      )
      if d_in == 0 or d_out == 0:
          return None
      h = 500
      n = data.train_x.shape[0] // 200
  
      logging.info(f"start training...")
      logging.info(
          f"  d_in = {d_in}, h = {h}, d_out = {d_out}, n = {n}"
      )
      st = time.process_time()
  
      self._model = LinearNet(d_in, h, d_out)
      if self._device is not None and self._device.type == "cuda":
          self._model = self._model.cuda()
      self._loss_fn = torch.nn.MSELoss(reduction="mean")
      learning_rate = 1e-3
      optimizer = torch.optim.Adam(
          self._model.parameters(), lr=learning_rate
      )
      scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(
          optimizer, "min", patience=5, verbose=True, threshold=1e-5
      )
      for _ in range(epochs):
          for t in range(iterations):
              x, y, _ = super()._sample(
                  data.train_x,
                  data.train_y,
                  data.train_weight,
                  num_samples,
                  True,
              )
              x = torch.as_tensor(x, device=self._device)
              y = torch.as_tensor(y, device=self._device)
              if len(y.shape) == 1:
                  y = y.reshape(-1, 1)
              y_pred = self._model(x)
              # pyre-fixme[29]: `Optional[torch.nn.MSELoss]` is not a function.
              loss = self._loss_fn(y_pred, y)
              if (t + 1) % 10 == 0:
                  scheduler.step(loss.item())
                  logging.info(f"  step [{t + 1}]: loss={loss.item()}")
  
              optimizer.zero_grad()
              loss.backward()
              optimizer.step()
  
      logging.info(f"  training time {time.process_time() - st}")
  
imports: import logging
  import math
  import time
  from typing import Optional
  import numpy
  import torch
  from reagent.ope.estimators.types import PredictResults, Trainer, TrainingData
  from sklearn.linear_model import Lasso, LogisticRegression, SGDClassifier
  from sklearn.metrics import accuracy_score, mean_squared_error
  from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
  from torch import Tensor
label_desc: Use image node_id 3 for calling the NNTrainer obj's underlying member method code with example usage: obj.train(data, iterations, epochs, num_samples) and returns: None