code: def _transpose(xs, length):
      if length == 0:
          return ()
  
      xp = backend.get_array_module(*xs)
      lengths = numpy.empty(length, dtype=numpy.int32)
      end = length
      for i, x in enumerate(xs):
          len_x = len(x)
          if len_x == end:
              continue
          lengths[len_x:end] = i
          end = len_x
      lengths[0:end] = len(xs)
  
      if xp is numpy:
          dtype = xs[0].dtype
          unit = xs[0].shape[1:]
  
          outs = tuple(
              [xp.empty((l,) + unit, dtype=dtype) for l in lengths]
          )
          for i, x in enumerate(xs):
              for p, xi in enumerate(x):
                  outs[p][i] = xi
  
      else:
          offsets1 = numpy.empty(len(xs) + 1, dtype=numpy.int32)
          offsets1[0] = 0
          numpy.cumsum([len(x) for x in xs], out=offsets1[1:])
  
          offsets2 = numpy.empty(length + 1, dtype=numpy.int32)
          offsets2[0] = 0
          numpy.cumsum(lengths, dtype=numpy.int32, out=offsets2[1:])
  
          x = xp.concatenate(xs, axis=0)
          o = xp.empty_like(x)
          unit = xs[0].size // len(xs[0])
          size = length * len(xs) * unit
          cuda.elementwise(
              "int32 len, int32 unit, raw int32 off1, raw int32 off2, raw T vs",
              "raw T hs",
              """
              int ind = i / unit;
              int off = i - ind * unit;
              int y = ind / len;
              int x = ind - y * len;
              if (off2[x] + y < off2[x + 1]) {
                hs[(off2[x] + y) * unit + off] = vs[(off1[y] + x) * unit + off];
              }
              """,
              "transpose_sequence",
          )(
              length,
              unit,
              cuda.to_gpu(offsets1),
              cuda.to_gpu(offsets2),
              x,
              o,
              size=size,
          )
          outs = tuple(xp.split(o, offsets2[1:-1]))
  
      return outs
  
file_path: chainer/chainer/functions/array/transpose_sequence.py
imports: import numpy
  from chainer import backend
  from chainer.backends import cuda
  from chainer import function_node
  from chainer.utils import type_check
label_desc: Use image node_id 1 for calling a global function with example usage: _transpose(xs, length) and returns: outs, 