code: def prune_chunk_graph(chunk_graph: ChunkGraph):
      from ....core.operand import Fetch, VirtualOperand, ShuffleProxy
  
      result_set = set(chunk_graph.result_chunks)
      stack = list(chunk_graph.result_chunks)
      used = set()
      while stack:
          n = stack.pop()
          if n in used:
              continue
          used.add(n)
          stack.extend(chunk_graph.predecessors(n))
          if isinstance(n.op, ShuffleProxy):
              stack.extend(
                  succ
                  for succ in chunk_graph.iter_successors(n)
                  if succ not in used
              )
  
      unused = {n for n in chunk_graph if n not in used}
      for n in unused:
          # for pruned chunks, we assume we will use them later,
          # so we add the inputs of them into result chunks,
          # to prevent from duplicated submission
          for inp in chunk_graph.iter_predecessors(n):
              if (
                  inp in used
                  and inp not in result_set
                  and not isinstance(inp.op, (Fetch, VirtualOperand))
              ):
                  chunk_graph.result_chunks.append(inp)
                  result_set.add(inp)
          # prune chunk
          chunk_graph.remove_node(n)
  
imports: import dataclasses
  import functools
  from typing import Callable, Dict, Generator, Iterable, List, Optional, Set, Type, Union
  from ....core import FUSE_CHUNK_TYPE, CHUNK_TYPE, TILEABLE_TYPE
  from ....typing import EntityType, TileableType, ChunkType
  from ....utils import copy_tileables, build_fetch
  from ...entity.tileables import handler
  from ...mode import enter_mode
  from ..entity import TileableGraph, ChunkGraph
  from .base import AbstractGraphBuilder
label_desc: Use image node_id 1 for calling a global function with example usage: prune_chunk_graph(chunk_graph) without return types