code: def filter_graph_collapse_sequence(graph, sequence):
      exclude_nodes = []
  
      for node in graph.nodes:
          remainder = sequence[:]
          matches = []
          while remainder:
              if len(node.consumers) > 1 and len(remainder) > 1:
                  break
              if node.op == remainder[0]:
                  matches.append(node.name)
                  node = node.consumers[0]
                  remainder = remainder[1:]
              else:
                  break
          if len(remainder) == 0:
              exclude_nodes += matches[:-1]
  
      include_nodes = [
          node.name
          for node in graph.nodes
          if node.name not in exclude_nodes
      ]
  
      return filter_graph(graph, include_nodes)
  
imports: import numpy
  import tensorflow
  import lucid.modelzoo.vision_models
  import lucid.optvis.objectives
  import lucid.optvis.param
  import lucid.optvis.render
  from lucid.misc.io import show, load
  from lucid.misc.io.showing import _image_url, _display_html
  from collections import defaultdict
label_desc: Use image node_id 5 for calling a global function with example usage: filter_graph_collapse_sequence(graph, sequence) and returns: filter_graph