code: def test_sortagrad_trainable_with_batch_frames(module, num_encs):
      args = make_arg(num_encs=num_encs, sortagrad=1)
      idim = 2
      odim = 2
      dummy_json = make_dummy_json(
          4, [2, 3], [2, 3], idim=idim, odim=odim, num_inputs=num_encs
      )
      import espnet.nets.pytorch_backend.e2e_asr_mulenc as m
  
      batch_frames_in = 50
      batch_frames_out = 50
      batchset = make_batchset(
          dummy_json,
          batch_frames_in=batch_frames_in,
          batch_frames_out=batch_frames_out,
          shortest_first=True,
      )
      for batch in batchset:
          i = 0
          o = 0
          for uttid, info in batch:
              i += int(
                  info["input"][0]["shape"][0]
              )  # based on the first input
              o += int(info["output"][0]["shape"][0])
          assert i <= batch_frames_in
          assert o <= batch_frames_out
  
      model = m.E2E([2 for _ in range(num_encs)], 2, args)
      for batch in batchset:
          loss = model(
              *convert_batch(
                  batch, module, idim=2, odim=2, num_inputs=num_encs
              )
          )
          loss.backward()  # trainable
      with torch.no_grad():
          in_data = [np.random.randn(100, 2) for _ in range(num_encs)]
          model.recognize(in_data, args, args.char_list)
  
imports: from __future__ import division
  import argparse
  import importlib
  import os
  import tempfile
  from test.utils_test import make_dummy_json
  import numpy
  import pytest
  import torch
  from espnet.nets.pytorch_backend.nets_utils import pad_list
  from espnet.utils.training.batchfy import make_batchset
label_desc: Use image node_id 8 for calling a global function with example usage: test_sortagrad_trainable_with_batch_frames(module, num_encs) without return types