code: def create_cascader_graph(
      te_graph: TESubgraph,
      const_dict: Dict[int, np.ndarray],
      device_config: EthosuDeviceConfig,
  ) -> CascaderGraph:
      """Create a CascaderGraph from a Tensor Expression graph and constant dictionary.
  
      Parameters
      ----------
      te_graph : TESubgraph
          The Tensor Expression graph.
      const_dict : Dict[int, np.ndarray]
          The constant dictionary.
      device_config : EthosuDeviceConfig
          Target device configuration.
  
      Returns
      -------
      CascaderGraph
          The CascaderGraph.
      """
      tensor_map = {}
  
      def _visit_tensor(tensor):
          if tensor not in tensor_map:
              is_const = False
              # Logic to determine if the tensor is constant
              if tensor in list(te_graph.inputs):
                  i = list(te_graph.inputs).index(tensor)
                  if i in const_dict:
                      is_const = True
  
              # TODO(@mbaret): Calculate the compression ratio
              plan_tensor = Tensor(
                  tensor.shape,
                  tensor.dtype,
                  is_constant=is_const,
              )
              tensor_map[tensor] = plan_tensor
              if (
                  isinstance(tensor.op, te.PlaceholderOp)
                  or tensor in te_graph.inputs
              ):
                  return
  
              input_tensors = []
              # Check whether any of the registered matchers match the current tensor
              for matcher in REGISTERED_MATCHERS:
                  part = matcher(tensor, device_config)
                  if part:
                      input_tensors = part.subgraph.input_tensors
                      break
  
              assert (
                  part is not None
              ), f"The tensor {tensor} doesn't match any part."
              part.set_output(plan_tensor)
              plan_tensor.add_producer(part)
              for i, input_tensor in enumerate(input_tensors):
                  _visit_tensor(input_tensor)
                  part.set_input(i, tensor_map[input_tensor])
                  tensor_map[input_tensor].add_consumer(part)
  
      for output in te_graph.outputs:
          _visit_tensor(output)
  
      input_tensors = []
      for t in te_graph.inputs:
          # This is needed because sometimes there are orphaned constants
          if t in tensor_map:
              input_tensors.append(tensor_map[t])
  
      output_tensors = [tensor_map[t] for t in te_graph.outputs]
      return CascaderGraph(input_tensors, output_tensors)
  
imports: from typing import List, Dict
  from enum import IntEnum
  from collections import namedtuple
  import numpy
  import tvm._ffi
  from tvm import te
  from tvm.runtime import Object
  from .stripe_config import StripeConfig
  from .device_config import EthosuDeviceConfig
  from .None import _ffi_api
label_desc: Use image node_id 2 for calling a global function with example usage: create_cascader_graph(te_graph, const_dict, device_config) and returns: CascaderGraph