code: def _to_tensors(
      results,
      prepare_nodes: Sequence[Sequence[PrepareNode]],
      measure_nodes: Sequence[Sequence[MeasureNode]],
  ) -> List:
      """Process a flat list of execution results from all circuit fragments into the corresponding
      tensors.
  
      This function slices ``results`` according to the expected size of fragment tensors derived from
      the ``prepare_nodes`` and ``measure_nodes`` and then passes onto ``_process_tensor`` for further
      transformation.
  
      Args:
          results (tensor_like): A collection of execution results, provided as a flat tensor,
              corresponding to the expansion of circuit fragments in the communication graph over
              measurement and preparation node configurations. These results are processed into
              tensors by this function.
          prepare_nodes (Sequence[Sequence[PrepareNode]]): a sequence whose length is equal to the
              number of circuit fragments, with each element used here to determine the number of
              preparation nodes in a given fragment
          measure_nodes (Sequence[Sequence[MeasureNode]]): a sequence whose length is equal to the
              number of circuit fragments, with each element used here to determine the number of
              measurement nodes in a given fragment
  
      Returns:
          List[tensor_like]: the tensors for each circuit fragment in the communication graph
      """
      ctr = 0
      tensors = []
  
      for p, m in zip(prepare_nodes, measure_nodes):
          n_prep = len(p)
          n_meas = len(m)
          n = n_prep + n_meas
  
          dim = 4**n
          results_slice = results[ctr : dim + ctr]
  
          tensors.append(_process_tensor(results_slice, n_prep, n_meas))
  
          ctr += dim
  
      if results.shape[0] != ctr:
          raise ValueError(
              f"The results argument should be a flat list of length {ctr}"
          )
  
      return tensors
  
file_path: pennylane/pennylane/qcut/processing.py
imports: import string
  from typing import List, Sequence
  from networkx import MultiDiGraph
  import pennylane
  from pennylane import numpy
  from .utils import MeasureNode, PrepareNode
label_desc: Use image node_id 8 for calling a global function with example usage: _to_tensors(results, prepare_nodes, measure_nodes) and returns: tensors