code: def test_crf_decode_torchscript(self, num_tags, seq_lens):
      crf_model = CRF(
          num_tags,
          ignore_index=Padding.WORD_LABEL_PAD_IDX,
          default_label_pad_index=Padding.DEFAULT_LABEL_PAD_IDX,
      )
      crf_model.eval()
      scripted_crf_model = torch.jit.script(crf_model)
  
      max_num_words = max(seq_lens)
      padded_inputs = []
      for seq_len in seq_lens:
          input_emission = np.random.rand(seq_len, num_tags)
          padded_inputs.append(
              np.concatenate(
                  [
                      input_emission,
                      np.zeros((max_num_words - seq_len, num_tags)),
                  ],
                  axis=0,
              )
          )
          crf_decode = crf_model.decode(
              torch.tensor(input_emission, dtype=torch.float).unsqueeze(
                  0
              ),
              torch.tensor([seq_len]),
          )
  
          scripted_crf_decode = scripted_crf_model.decode(
              torch.tensor(input_emission, dtype=torch.float).unsqueeze(
                  0
              ),
              torch.tensor([seq_len]),
          )
  
          self.assertTrue(
              torch.allclose(crf_decode, scripted_crf_decode)
          )
  
      batched_emissions = torch.tensor(padded_inputs, dtype=torch.float)
      batched_seq_lens = torch.tensor(seq_lens)
      crf_batch_decode = crf_model.decode(
          batched_emissions, batched_seq_lens
      )
      scriped_crf_batch_decode = scripted_crf_model.decode(
          batched_emissions, batched_seq_lens
      )
      self.assertTrue(
          torch.allclose(crf_batch_decode, scriped_crf_batch_decode)
      )
  
file_path: pytext/pytext/models/test/crf_test.py
imports: import caffe2.python.hypothesis_test_util
  import hypothesis.strategies
  import numpy
  import torch
  from hypothesis import given, settings
  from pytext.common.constants import Padding
  from pytext.models.crf import CRF
  from scipy.special import logsumexp
label_desc: Use image node_id 3 for calling the CRFTest obj's underlying member method code with example usage: obj.test_crf_decode_torchscript(num_tags, seq_lens) without return types