code: def recursive_length(tensor, lod_level):
      def _recurse(data, result, level):
          if level > 0:
              if isinstance(data, (TensorListCPU, TensorListGPU)):
                  # handle tensor list
                  length = len(data)
                  result[0].append(length)
                  for i in range(length):
                      _recurse(data.at(i), result[1:], level - 1)
              elif hasattr(data, "shape"):
                  # handle dense GPU tensors and numpy.ndarray
                  shape = data.shape
                  if callable(shape):
                      shape = shape()
                  length = shape[0]
                  result[0].append(length)
                  for i in range(length):
                      _recurse(shape[1:], result[1:], level - 1)
              else:
                  # handle shape
                  length = data[0]
                  result[0].append(length)
                  for i in range(length):
                      _recurse(data[1:], result[1:], level - 1)
  
      seq_len = [[] for _ in range(lod_level)]
      _recurse(tensor, seq_len, lod_level)
      return seq_len
  
file_path: DALI/dali/python/nvidia/dali/plugin/paddle.py
imports: import ctypes
  import math
  import numpy
  import paddle
  from distutils.version import LooseVersion
  from nvidia.dali import types
  from nvidia.dali.backend import TensorListCPU, TensorGPU, TensorListGPU
  from nvidia.dali.plugin.base_iterator import _DaliBaseIterator
  from nvidia.dali.plugin.base_iterator import LastBatchPolicy
label_desc: Use image node_id 3 for calling a global function with example usage: recursive_length(tensor, lod_level) and returns: seq_len