class_docstr: Dumpt a DL graph into a Python script.
class_docstr_tok: ["Dumpt","a","DL","graph","into","a","Python","script","."]
code: def emit(self):
      # Decompose DAG into chains
      chains = []
      for node in self.graph.topologically_sorted():
          attach_to_chain = None
          if len(node.input) == 1:
              parent = get_real_name(node.input[0])
              for chain in chains:
                  if (
                      chain[-1].name == parent
                  ):  # Node is part of an existing chain.
                      attach_to_chain = chain
                      break
          if (
              attach_to_chain is None
          ):  # Start a new chain for this node.
              attach_to_chain = []
              chains.append(attach_to_chain)
          attach_to_chain.append(node)
  
      # Generate Python code line by line
      source = self.emit_imports()
      source += self.emit_class_def(self.graph.name)
      self.indent()
      source += self.emit_setup_def()
      self.indent()
      blocks = []
      for chain in chains:
          b = ""
          for node in chain:
              b += self.emit_node(node)
          blocks.append(b[:-1])
      source += "\n\n".join(blocks)
      return source
  
imports: import base64
  from google.protobuf import json_format
  from importlib import import_module
  import json
  import numpy
  import os
  import sys
  from mmdnn.conversion.caffe.errors import ConversionError
  from mmdnn.conversion.caffe.common_graph import fetch_attr_value
  from mmdnn.conversion.caffe.utils import get_lower_case, get_upper_case, get_real_name
label_desc: Use image node_id 10 for calling the PyWriter obj's underlying member method code with example usage: obj.emit() and returns: source