# Path: pycoral/utils/edgetpu.py
# _EDGETPU_SHARED_LIB = {
#   'Linux': 'libedgetpu.so.1',
#   'Darwin': 'libedgetpu.1.dylib',
#   'Windows': 'edgetpu.dll'
# }[platform.system()]
# def load_edgetpu_delegate(options=None):
# def make_interpreter(model_path_or_content, device=None, delegate=None):
# def _is_valid_ctypes_input(input_data):
# def _gst_buffer_map(buffer):
# def _check_input_size(input_size, expected_input_size):
# def run_inference(interpreter, input_data):
# class _GstMapInfo(ctypes.Structure):
# 
# Path: tests/test_utils.py
# _TEST_DATA_DIR = ''
#   _TEST_DATA_DIR = args.test_data_dir
# def get_test_tmpdir():
# def test_data_path(path, *paths):
# def test_image(path, *paths):
# def temporary_file(suffix=None):
# def generate_random_input(seed, n):
# def prepare_images(image_list, directory, shape):
# def area(box):
# def iou(box_a, box_b):
# def prepare_data_set_from_directory(path, test_ratio, fixed_order):
# def coral_test_main():


import ctypes
import ctypes.util
import io
import numpy as np
import unittest
  import gi
from pycoral.utils import edgetpu
from tests import test_utils
  from gi.repository import Gst
    edgetpu.run_inference(
        interpreter, (np_input.ctypes.data_as(ctypes.c_void_p), np_input.size))
    ret = interpreter.tensor(output_index)()
    self.assertTrue(np.array_equal(ret0, ret))
    # Gst buffer
    if _libgst:
      gst_input = Gst.Buffer.new_wrapped(bytes_input)
      edgetpu.run_inference(interpreter, gst_input)
      ret = interpreter.tensor(output_index)()
      self.assertTrue(np.array_equal(ret0, ret))
    else:
      print('Can not import gi. Skip test on Gst.Buffer input type.')

  def _run_inference_with_gst(self, interpreter, input_data):
    output_index = interpreter.get_output_details()[0]['index']
    bytes_input = bytes(input_data)
    gst_input = Gst.Buffer.new_wrapped(bytes_input)
    edgetpu.run_inference(interpreter, gst_input)
    ret = interpreter.tensor(output_index)()
    return np.copy(ret)

  def test_run_inference_with_different_types(self):
    interpreter = edgetpu.make_interpreter(
        self._default_test_model_path(), delegate=self.delegate)
    interpreter.allocate_tensors()
    input_size = required_input_array_size(interpreter)
    input_data = test_utils.generate_random_input(1, input_size)
    self._run_inference_with_different_input_types(interpreter, input_data)

  def test_run_inference_larger_input_size(self):

# Path: pycoral/utils/edgetpu.py
# _EDGETPU_SHARED_LIB = {
#   'Linux': 'libedgetpu.so.1',
#   'Darwin': 'libedgetpu.1.dylib',
#   'Windows': 'edgetpu.dll'
# }[platform.system()]
# def load_edgetpu_delegate(options=None):
# def make_interpreter(model_path_or_content, device=None, delegate=None):
# def _is_valid_ctypes_input(input_data):
# def _gst_buffer_map(buffer):
# def _check_input_size(input_size, expected_input_size):
# def run_inference(interpreter, input_data):
# class _GstMapInfo(ctypes.Structure):
# 
# Path: tests/test_utils.py
# _TEST_DATA_DIR = ''
#   _TEST_DATA_DIR = args.test_data_dir
# def get_test_tmpdir():
# def test_data_path(path, *paths):
# def test_image(path, *paths):
# def temporary_file(suffix=None):
# def generate_random_input(seed, n):
# def prepare_images(image_list, directory, shape):
# def area(box):
# def iou(box_a, box_b):
# def prepare_data_set_from_directory(path, test_ratio, fixed_order):
# def coral_test_main():


# Path: tests/edgetpu_utils_test.py
import ctypes
import ctypes.util
import io
import numpy as np
import unittest
  import gi
from pycoral.utils import edgetpu
from tests import test_utils
  from gi.repository import Gst

    edgetpu.run_inference(
        interpreter, (np_input.ctypes.data_as(ctypes.c_void_p), np_input.size))
    ret = interpreter.tensor(output_index)()
    self.assertTrue(np.array_equal(ret0, ret))
    # Gst buffer
    if _libgst:
      gst_input = Gst.Buffer.new_wrapped(bytes_input)
      edgetpu.run_inference(interpreter, gst_input)
      ret = interpreter.tensor(output_index)()
      self.assertTrue(np.array_equal(ret0, ret))
    else:
      print('Can not import gi. Skip test on Gst.Buffer input type.')

  def _run_inference_with_gst(self, interpreter, input_data):
    output_index = interpreter.get_output_details()[0]['index']
    bytes_input = bytes(input_data)
    gst_input = Gst.Buffer.new_wrapped(bytes_input)
    edgetpu.run_inference(interpreter, gst_input)
    ret = interpreter.tensor(output_index)()
    return np.copy(ret)

  def test_run_inference_with_different_types(self):
    interpreter = edgetpu.make_interpreter(
        self._default_test_model_path(), delegate=self.delegate)
    interpreter.allocate_tensors()
    input_size = required_input_array_size(interpreter)
    input_data = test_utils.generate_random_input(1, input_size)
    self._run_inference_with_different_input_types(interpreter, input_data)

  def test_run_inference_larger_input_size(self):

    interpreter = edgetpu.make_interpreter(