code: def test_sortagrad_trainable_with_batch_frames(module):
      args = make_arg(sortagrad=1)
      idim = 20
      odim = 5
      dummy_json = make_dummy_json_st(
          4, [10, 20], [10, 20], [10, 20], idim=idim, odim=odim
      )
      if module == "pytorch":
          import espnet.nets.pytorch_backend.e2e_st as m
      else:
          raise NotImplementedError
      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])
              o += int(info["output"][0]["shape"][0])
          assert i <= batch_frames_in
          assert o <= batch_frames_out
  
      model = m.E2E(20, 5, args)
      for batch in batchset:
          loss = model(*convert_batch(batch, module, idim=20, odim=5))
          if isinstance(loss, tuple):
              # chainer return several values as tuple
              loss[0].backward()  # trainable
          else:
              loss.backward()  # trainable
      with torch.no_grad(), chainer.no_backprop_mode():
          in_data = np.random.randn(100, 20)
          model.translate(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_st
  import chainer
  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) without return types