class_docstr: Converts TensorFlow flatbuffer models from old to new version of schema.
  
  This can convert between any version to the latest version. It uses
  an incremental upgrade strategy to go from version to version.
  
  Usage:
    converter = Converter()
    converter.Convert("a.tflite", "a.json")
    converter.Convert("b.json", "b.tflite")
class_docstr_tok: ["Converts","TensorFlow","flatbuffer","models","from","old","to","new","version","of","schema",".","This","can","convert","between","any","version","to","the","latest","version",".","It","uses","an","incremental","upgrade","strategy","to","go","from","version","to","version",".","Usage",":","converter","=","Converter","(",")","converter.Convert","(","``","a.tflite","''",",","``","a.json","''",")","converter.Convert","(","``","b.json","''",",","``","b.tflite","''",")"]
docstr: Output a json or bin version of the flatbuffer model.
  
  Args:
    data: Dict representing the TensorFlow Lite model to write.
    output_file: filename to write the converted flatbuffer to. (json,
      tflite, or bin extension is required).
  Raises:
    ValueError: When the extension is not json or bin
    RuntimeError: When flatc fails to convert json data to binary.
docstr_tok: ["Output","a","json","or","bin","version","of","the","flatbuffer","model",".","Args",":","data",":","Dict","representing","the","TensorFlow","Lite","model","to","write",".","output_file",":","filename","to","write","the","converted","flatbuffer","to",".","(","json",",","tflite",",","or","bin","extension","is","required",")",".","Raises",":","ValueError",":","When","the","extension","is","not","json","or","bin","RuntimeError",":","When","flatc","fails","to","convert","json","data","to","binary","."]
code: def _Write(self, data, output_file):
      """Output a json or bin version of the flatbuffer model.
  
      Args:
        data: Dict representing the TensorFlow Lite model to write.
        output_file: filename to write the converted flatbuffer to. (json,
          tflite, or bin extension is required).
      Raises:
        ValueError: When the extension is not json or bin
        RuntimeError: When flatc fails to convert json data to binary.
      """
      _, extension = os.path.splitext(output_file)
      with TemporaryDirectoryResource() as tempdir:
          if extension == ".json":
              json.dump(
                  data, open(output_file, "w"), sort_keys=True, indent=2
              )
          elif extension in [".tflite", ".bin"]:
              input_json = os.path.join(tempdir, "temp.json")
              with open(input_json, "w") as fp:
                  json.dump(data, fp, sort_keys=True, indent=2)
              returncode = subprocess.call(
                  [
                      self._flatc_path,
                      "-b",
                      "--defaults-json",
                      "--strict-json",
                      "-o",
                      tempdir,
                      self._new_schema,
                      input_json,
                  ]
              )
              if returncode != 0:
                  raise RuntimeError(
                      "flatc failed to convert upgraded json to binary."
                  )
  
              shutil.copy(
                  os.path.join(tempdir, "temp.tflite"), output_file
              )
          else:
              raise ValueError(
                  "Invalid extension on output file %r" % output_file
              )
  
imports: import argparse
  import contextlib
  import json
  import os
  import shutil
  import subprocess
  import sys
  import tempfile
  import tensorflow
  from tensorflow.python.platform import resource_loader
label_desc: Use image node_id 3 for calling the Converter obj's underlying member method code with example usage: obj._Write(data, output_file) without return types