code: def test_transformerlmrescorer(tmpdir, device):
      import torch
      from sentencepiece import SentencePieceProcessor
      from speechbrain.lobes.models.transformer.TransformerLM import (
          TransformerLM,
      )
      from speechbrain.utils.parameter_transfer import Pretrainer
  
      source = "speechbrain/asr-transformer-transformerlm-librispeech"
      lm_model_path = source + "/lm.ckpt"
      tokenizer_path = source + "/tokenizer.ckpt"
      tokenizer = SentencePieceProcessor()
  
      lm_model = TransformerLM(
          vocab=5000,
          d_model=768,
          nhead=12,
          num_encoder_layers=12,
          num_decoder_layers=0,
          d_ffn=3072,
          dropout=0.0,
          activation=torch.nn.GELU,
          normalize_before=False,
      )
  
      pretrainer = Pretrainer(
          collect_in=tmpdir,
          loadables={"lm": lm_model, "tokenizer": tokenizer},
          paths={"lm": lm_model_path, "tokenizer": tokenizer_path},
      )
  
      _ = pretrainer.collect_files()
      pretrainer.load_collected()
  
      from speechbrain.decoders.scorer import (
          TransformerLMRescorer,
          RescorerBuilder,
      )
  
      transformerlm_rescorer = TransformerLMRescorer(
          language_model=lm_model,
          tokenizer=tokenizer,
          temperature=1.0,
          bos_index=1,
          eos_index=2,
          pad_index=0,
      )
  
      rescorer = RescorerBuilder(
          rescorers=[transformerlm_rescorer],
          weights={"transformerlm": 1.0},
      )
  
      # Topk hypotheses
      topk_hyps = [["HELLO", "HE LLO", "H E L L O"]]
      topk_scores = [[-2, -2, -2]]
      rescored_hyps, rescored_scores = rescorer.rescore(
          topk_hyps, topk_scores
      )
  
      # check all hyps are still there
      for hyp in topk_hyps[0]:
          assert hyp in rescored_hyps[0]
  
      # check rescored_scores are sorted
      for i in range(len(rescored_scores[0]) - 1):
          assert rescored_scores[0][i] >= rescored_scores[0][i + 1]
  
      # check normalized_text is working
      text = "hello"
      normalized_text = transformerlm_rescorer.normalize_text(text)
      assert normalized_text == text.upper()
  
      # check lm is on the right device
      transformerlm_rescorer.to_device(device)
      assert (
          transformerlm_rescorer.lm.parameters().__next__().device.type
          == device
      )
  
      # check preprocess_func
      (
          padded_hyps,
          enc_hyps_length,
      ) = transformerlm_rescorer.preprocess_func(topk_hyps)
      assert padded_hyps.shape[0] == 3
      assert len(padded_hyps) == 3
  
label_desc: Use image node_id 2 for calling a global function with example usage: test_transformerlmrescorer(tmpdir, device) without return types