code: def test_train_eval_loss(self):
      cfg = get_cfg()
      cfg.label_smoothing = 0.5
      model = MTEncDecModel(cfg=cfg)
      assert isinstance(model, MTEncDecModel)
      batch_size = 10
      time = 32
      vocab_size = 32000
      torch.manual_seed(42)
      tgt_ids = torch.LongTensor(batch_size, time).random_(
          1, model.decoder_tokenizer.vocab_size
      )
      logits = torch.FloatTensor(batch_size, time, vocab_size).random_(
          -1, 1
      )
      log_probs = torch.nn.functional.log_softmax(logits, dim=-1)
      train_loss = model.loss_fn(log_probs=log_probs, labels=tgt_ids)
      eval_loss = model.eval_loss_fn(
          log_probs=log_probs, labels=tgt_ids
      )
      assert not torch.allclose(
          train_loss, eval_loss
      )  # , (train_loss, eval_loss)
  
      cfg.label_smoothing = 0
      model = MTEncDecModel(cfg=cfg)
      # Train loss == val loss when label smoothing = 0
      train_loss = model.loss_fn(log_probs=log_probs, labels=tgt_ids)
      eval_loss = model.eval_loss_fn(
          log_probs=log_probs, labels=tgt_ids
      )
      assert torch.allclose(train_loss, eval_loss)
  
file_path: NeMo/tests/collections/nlp/test_nmt_model.py
imports: import os
  import shutil
  import tempfile
  import pytest
  import torch
  from omegaconf import DictConfig, OmegaConf
  from nemo.collections.nlp.models import MTEncDecModel
  from nemo.collections.nlp.models.machine_translation.mt_enc_dec_config import AAYNBaseConfig
label_desc: Use image node_id 3 for calling the TestMTEncDecModel obj's underlying member method code with example usage: obj.test_train_eval_loss() without return types