code: def test_forward_infer(self, msdd_model):
      diar_model = msdd_model.eval()
  
      # batch_size 4, scale_n 5, length 25, emb_dim 192
      input_signal = torch.randn(size=(4, 25, 5, 192))
      input_signal_length = 25 * torch.ones(4, dtype=torch.int)
      emb_vectors = torch.randn(size=(4, 5, 192, 2))
      targets = torch.randint(2, size=(4, 25, 2), dtype=torch.int)
  
      with torch.no_grad():
          # batch size 1
          preds_list, scale_weights_list = [], []
          for i in range(input_signal.size(0)):
              preds, scale_weights = diar_model.forward_infer(
                  input_signal[i : i + 1],
                  input_signal_length[i : i + 1],
                  emb_vectors[i : i + 1],
                  targets[i : i + 1],
              )
              preds_list.append(preds)
              scale_weights_list.append(scale_weights)
          preds_instance = torch.cat(preds_list, 0)
          scale_weights_instance = torch.cat(scale_weights_list, 0)
  
          # batch size 4
          preds_batch, scale_weights_batch = diar_model.forward_infer(
              input_signal, input_signal_length, emb_vectors, targets
          )
  
      assert preds_instance.shape == preds_batch.shape
      assert scale_weights_instance.shape == scale_weights_batch.shape
  
      diff = torch.mean(torch.abs(preds_instance - preds_batch))
      assert diff <= 1e-6
      diff = torch.max(torch.abs(preds_instance - preds_batch))
      assert diff <= 1e-6
      diff = torch.mean(
          torch.abs(scale_weights_instance - scale_weights_batch)
      )
      assert diff <= 1e-6
      diff = torch.max(
          torch.abs(scale_weights_instance - scale_weights_batch)
      )
      assert diff <= 1e-6
  
imports: import pytest
  import torch
  from omegaconf import DictConfig
  from nemo.collections.asr.models import EncDecDiarLabelModel
label_desc: Use image node_id 2 for calling the TestEncDecDiarLabelModel obj's underlying member method code with example usage: obj.test_forward_infer(msdd_model) without return types