code: def _add_graph(graph, builder, use_file=True):
      if use_file:
          # TODO: remove the dir and honor the existing one
          d = tempfile.mkdtemp("tensorframes", dir="/tmp")
          tf.train.write_graph(graph, d, "proto.pb", False)
          fname = d + "/proto.pb"
          builder.graphFromFile(fname)
      else:
          # Make sure that TF adds the shapes.
          gser = graph.as_graph_def(add_shapes=True).SerializeToString()
          gbytes = bytearray(gser)
          builder.graph(gbytes)
  
imports: import tensorflow
  import numpy
  import logging
  import tempfile
  import pandas
  from pyspark import RDD, SparkContext
  from pyspark.sql import SQLContext, Row, DataFrame
  from pyspark.sql.types import DoubleType, IntegerType, LongType, FloatType, ArrayType
label_desc: Use image node_id 4 for calling a global function with example usage: _add_graph(graph, builder, use_file) without return types