code: def train(
      self,
      num_itr,
      display_itr,
      update_itr,
      eval_datasets=[],
      evaluators=[],
  ):
      acc_loss = 0
  
      for itr in range(num_itr):
          batch_data = self._sampler.next_batch()
          loss = self._model.train(batch_data)
          acc_loss += loss
          if itr % display_itr == 0 and itr > 0:
              print(
                  colored("[Itr %d]" % itr, "red"),
                  "loss: %f" % (acc_loss / display_itr),
                  "mse: %f"
                  % (acc_loss * 2 / (display_itr * self._batch_size)),
              )
              for dataset in eval_datasets:
                  print(
                      colored(
                          "..(dataset: %s) evaluation" % dataset.name,
                          "green",
                      )
                  )
                  sys.stdout.flush()
                  eval_results = self._evaluate(
                      eval_dataset=dataset, evaluators=evaluators
                  )
                  for key, result in eval_results.items():
                      average_result = np.mean(result, axis=0)
                      if type(average_result) is np.ndarray:
                          print(
                              colored(
                                  "..(dataset: %s)" % dataset.name,
                                  "green",
                              ),
                              key,
                              " ".join(
                                  [str(s) for s in average_result]
                              ),
                          )
                      else:
                          print(
                              colored(
                                  "..(dataset: %s)" % dataset.name,
                                  "green",
                              ),
                              key,
                              average_result,
                          )
              acc_loss = 0
  
          if itr % update_itr == 0 and itr > 0:
              self._model.update_embeddings()
  
file_path: openrec/openrec/tf1/legacy/itr_mlp_model_trainer.py
imports: from __future__ import print_function
  from tqdm import tqdm
  import math
  from termcolor import colored
  import numpy
  import sys
label_desc: Use image node_id 2 for calling the ItrMLPModelTrainer obj's underlying member method code with example usage: obj.train(num_itr, display_itr, update_itr, eval_datasets, evaluators) without return types