code: def _nested_stack(res):
      """
      Given a list of identical nested tuple structures, stack the arrays at the leaves
      """
      # for some reason pylint thinks qml.numpy.builtins is a dict
      # pylint: disable=no-member
      if not isinstance(
          res[0], (tuple, qml.numpy.builtins.SequenceBox)
      ):
          return qml.math.stack(res)
  
      stacked_results = []
      for i in range(len(res[0])):
          stacked_results.append(_nested_stack([r[i] for r in res]))
  
      return tuple(stacked_results)
  
imports: from typing import Callable, Sequence
  import pennylane
  from .core import transform
label_desc: Use image node_id 1 for calling a global function with example usage: _nested_stack(res) and returns: tuple, qml