code: def save_graph_to_code(j2_env, model_tag, graph_idx, graph, output):
      graph_tag = graph.name
      template_name = "tensor_source.jinja2"
      counter = 0
      for tensor in graph.tensors:
          # convert tensor
          source = j2_env.get_template(template_name).render(
              tensor=tensor,
              tensor_id=counter,
              model_tag=model_tag,
              graph_tag=graph_tag,
          )
          cc_path = (
              output
              + "/"
              + graph_tag
              + "_tensor"
              + str(counter)
              + ".cc"
          )
          with open(cc_path, "w") as f:
              f.write(source)
          counter += 1
  
      template_name = "operator.jinja2"
      counter = 0
      op_size = len(graph.op)
      device = 0
      for arg in graph.arg:
          if arg.name == MaceKeyword.mace_runtime_type_str:
              device = arg.i
      for start in range(0, op_size, 10):
          source = j2_env.get_template(template_name).render(
              start=start,
              end=min(start + 10, op_size),
              net=graph,
              model_tag=model_tag,
              graph_tag=graph_tag,
              device=device,
          )
          cc_path = (
              output + "/" + graph_tag + "_op" + str(counter) + ".cc"
          )
          with open(cc_path, "w") as f:
              f.write(source)
          counter += 1
  
      template_name = "graph.jinja2"
      source = j2_env.get_template(template_name).render(
          net=graph,
          graph_id=graph_idx,
          model_tag=model_tag,
          graph_tag=graph_tag,
      )
      with open(output + "/" + graph_tag + "_graph.cc", "w") as f:
          f.write(source)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import datetime
  import os
  import hashlib
  from jinja2 import Environment, FileSystemLoader
  from py_proto import mace_pb2
  from utils import device
  from utils import util
  from utils.util import mace_check
  from utils.util import MaceLogger
  from utils import config_parser
  from utils.config_parser import CPP_KEYWORDS
  from transform.base_converter import MaceKeyword
label_desc: Use image node_id 6 for calling a global function with example usage: save_graph_to_code(j2_env, model_tag, graph_idx, graph, output) without return types