code: def test_transformer_trainable_and_decodable(model_dict):
      args = make_arg(**model_dict)
      model, x, ilens, y_tgt, y_src, data, uttid_list = prepare(args)
  
      # test beam search
      trans_args = argparse.Namespace(
          beam_size=1,
          penalty=0.0,
          ctc_weight=0.0,
          maxlenratio=1.0,
          lm_weight=0,
          minlenratio=0,
          nbest=1,
          tgt_lang=False,
      )
      # test trainable
      optim = torch.optim.Adam(model.parameters(), 0.01)
      loss = model(x, ilens, y_tgt, y_src)
      optim.zero_grad()
      loss.backward()
      optim.step()
  
      # test attention plot
      attn_dict = model.calculate_all_attentions(
          x[0:1], ilens[0:1], y_tgt[0:1], y_src[0:1]
      )
      plot.plot_multi_head_attention(
          data, uttid_list, attn_dict, "", savefn=_savefn
      )
  
      # test CTC plot
      ctc_probs = model.calculate_all_ctc_probs(
          x[0:1], ilens[0:1], y_tgt[0:1], y_src[0:1]
      )
      if args.asr_weight > 0 and args.mtlalpha > 0:
          print(ctc_probs.shape)
      else:
          assert ctc_probs is None
  
      # test decodable
      with torch.no_grad():
          nbest = model.translate(
              x[0, : ilens[0]].numpy(), trans_args, args.char_list
          )
          print(y_tgt[0])
          print(nbest[0]["yseq"][1:-1])
  
file_path: espnet/test/test_e2e_st_transformer.py
imports: import argparse
  import pytest
  import torch
  from espnet.nets.pytorch_backend.e2e_st_transformer import E2E
  from espnet.nets.pytorch_backend.transformer import plot
label_desc: Use image node_id 4 for calling a global function with example usage: test_transformer_trainable_and_decodable(model_dict) without return types