code: def topologically_sorted(self):
      visited = set()
      sorted_nodes = []
  
      def topo_sort_dfs(node, visited, sorted_nodes):
          if node in visited:
              return
          visited.add(node)
          for n, idx in node.parents:
              topo_sort_dfs(n, visited, sorted_nodes)
          sorted_nodes.append(node)
  
      for node in self.nodes:
          topo_sort_dfs(node, visited, sorted_nodes)
      return sorted_nodes
  
imports: from collections import namedtuple
  from functools import reduce
  from google.protobuf import text_format
  from copy import deepcopy
  import numbers
  import os
  import tempfile
  from mmdnn.conversion.caffe.mapper import get_handler_name
  from mmdnn.conversion.caffe.resolver import get_caffe_resolver, has_pycaffe
  from mmdnn.conversion.caffe.shape import *
  from mmdnn.conversion.caffe.errors import print_stderr, ConversionError
label_desc: Use image node_id 6 for calling the CaffeGraph obj's underlying member method code with example usage: obj.topologically_sorted() and returns: sorted_nodes