docstr: With -inf eps penalty W-Transducer loss should be equivalent to RNN-T loss.
docstr_tok: ["With","-inf","eps","penalty","W-Transducer","loss","should","be","equivalent","to","RNN-T","loss","."]
code: def test_small_grid_transducer_inf_penalty(
      self,
      device,
      last_blank_mode,
      use_grid_implementation,
      rnnt_test_helper,
      rnn_loss_sample_data,
  ):
      """
      With -inf eps penalty W-Transducer loss should be equivalent to RNN-T loss.
      """
      sample_data = rnn_loss_sample_data.get_sample_small()
      graph_rnnt = GraphWTransducerLoss(
          blank=0,
          eps_weight=-100.0,
          last_blank_mode=last_blank_mode,
          use_grid_implementation=use_grid_implementation,
      )
      graph_cost, graph_grads = rnnt_test_helper.wrap_and_call(
          graph_rnnt, sample_data.logits, sample_data.targets, device
      )
      assert np.allclose(
          graph_cost, sample_data.expected_cost.numpy(), rtol=1e-6
      ), "costs mismatch."
      assert np.allclose(
          graph_grads, sample_data.expected_grads.numpy(), atol=1e-6
      ), "gradient mismatch."
  
file_path: NeMo/tests/collections/asr/k2/test_w_transducer.py
imports: from typing import List
  import numpy
  import pytest
  import torch
label_desc: Use image node_id 5 for calling the TestGraphWTransducerLoss obj's underlying member method code with example usage: obj.test_small_grid_transducer_inf_penalty(device, last_blank_mode, use_grid_implementation, rnnt_test_helper, rnn_loss_sample_data) without return types