code: def test_temporal_schema(
      self, device, blank_first, num_frames, vocab_size
  ):
      blank_id = 0 if blank_first else vocab_size - 1
      loss = GraphRnntLoss(blank=blank_id)
      temporal_schema = loss.get_temporal_schema(
          num_frames=num_frames,
          vocab_size=vocab_size,
          device=torch.device(device),
      )
  
      etalon_schema_fst: List[List[int]] = []
      for time_i in range(num_frames):
          for label_i in range(vocab_size):
              if label_i == blank_id:
                  # transition to the next state
                  etalon_schema_fst.append(
                      [time_i, time_i + 1, label_i, time_i, 0]
                  )
              else:
                  # self-loop
                  etalon_schema_fst.append(
                      [time_i, time_i, label_i, time_i, 0]
                  )
      etalon_schema_fst.append(
          [num_frames, num_frames + 1, -1, -1, 0]
      )  # transition to final state
      etalon_schema_fst.append([num_frames + 1])  # final state
      etalon_schema_fst = sorted(
          etalon_schema_fst
      )  # required for k2.Fsa.from_str
      etalon_schema_fst_str = "\n".join(
          [" ".join(map(str, line)) for line in etalon_schema_fst]
      )
      etalon_temporal_schema = k2.Fsa.from_str(
          etalon_schema_fst_str, num_aux_labels=1
      )
  
      assert temporal_schema.num_arcs == etalon_temporal_schema.num_arcs
      assert (
          temporal_schema.shape == etalon_temporal_schema.shape
      )  # (num_states, None)
      assert k2.is_rand_equivalent(
          temporal_schema,
          etalon_temporal_schema,
          log_semiring=True,
          treat_epsilons_specially=False,
      ), "Temporal schema mismatch"
      assert k2.is_rand_equivalent(
          temporal_schema.invert(),
          etalon_temporal_schema.invert(),
          log_semiring=True,
          treat_epsilons_specially=False,
      ), "Temporal schema output labels mismatch"
  
file_path: NeMo/tests/collections/asr/k2/test_graph_transducer.py
imports: from typing import List
  import numpy
  import pytest
  import torch
  from nemo.collections.asr.parts.numba.rnnt_loss.rnnt_numpy import RNNTLoss
label_desc: Use image node_id 1 for calling the TestGraphRnnt obj's underlying member method code with example usage: obj.test_temporal_schema(device, blank_first, num_frames, vocab_size) without return types