code: def recursive_map(seq, func):
      """This is similar to the build-in map function but works for nested lists.
      Useful for transforming tensors serialized with .tolist()
      """
      for item in seq:
          if isinstance(item, Sequence):
              yield type(item)(recursive_map(item, func))
          else:
              yield func(item)
  
imports: from collections.abc import Sequence
label_desc: Use image node_id 3 for calling a global function with example usage: recursive_map(seq, func) without return types