code: def test_dynamic_quantization(train_dic, recog_dic, quantize_dic):
      idim, odim, ilens, olens = get_default_scope_inputs()
  
      train_args = get_default_train_args(**train_dic)
      recog_args = get_default_recog_args(**recog_dic)
  
      model = E2E(idim, odim, train_args)
  
      if not is_torch_1_5_plus and (
          torch.nn.Linear in quantize_dic["mod"]
          and quantize_dic["dtype"] == torch.float16
      ):
          # In recognize(...) from asr.py we raise ValueError however
          # AssertionError is originaly raised by torch.
          with pytest.raises(AssertionError):
              model = torch.quantization.quantize_dynamic(
                  model,
                  quantize_dic["mod"],
                  dtype=quantize_dic["dtype"],
              )
          pytest.skip(
              "Skip rest of the test after checking AssertionError"
          )
      else:
          model = torch.quantization.quantize_dynamic(
              model,
              quantize_dic["mod"],
              quantize_dic["dtype"],
          )
  
      beam_search = BeamSearchTransducer(
          decoder=model.dec,
          joint_network=model.transducer_tasks.joint_network,
          beam_size=recog_args.beam_size,
          lm=recog_args.rnnlm,
          lm_weight=recog_args.lm_weight,
          search_type=recog_args.search_type,
          max_sym_exp=recog_args.max_sym_exp,
          u_max=recog_args.u_max,
          nstep=recog_args.nstep,
          prefix_alpha=recog_args.prefix_alpha,
          score_norm=recog_args.score_norm_transducer,
          quantization=True,
      )
  
      with torch.no_grad():
          in_data = np.random.randn(20, idim)
  
          if (
              not is_torch_1_4_plus
              and torch.nn.LSTM in quantize_dic["mod"]
          ):
              # Cf. previous comment
              with pytest.raises(AssertionError):
                  model.recognize(in_data, beam_search)
          else:
              model.recognize(in_data, beam_search)
  
imports: import argparse
  import json
  import tempfile
  import numpy
  import pytest
  import torch
  from packaging.version import parse
  import espnet.lm.pytorch_backend.extlm
  import espnet.nets.pytorch_backend.lm.default
  from espnet.asr.pytorch_backend.asr_init import load_trained_model
  from espnet.nets.beam_search_transducer import BeamSearchTransducer
  from espnet.nets.pytorch_backend.e2e_asr_transducer import E2E
  from espnet.nets.pytorch_backend.nets_utils import pad_list
label_desc: Use image node_id 12 for calling a global function with example usage: test_dynamic_quantization(train_dic, recog_dic, quantize_dic) without return types