class_docstr: Interpreter interface for running TensorFlow Lite models.
  
  Models obtained from `TfLiteConverter` can be run in Python with
  `Interpreter`.
  
  As an example, lets generate a simple Keras model and convert it to TFLite
  (`TfLiteConverter` also supports other input formats with `from_saved_model`
  and `from_concrete_function`)
  
  >>> x = np.array([[1.], [2.]])
  >>> y = np.array([[2.], [4.]])
  >>> model = tf.keras.models.Sequential([
  ...           tf.keras.layers.Dropout(0.2),
  ...           tf.keras.layers.Dense(units=1, input_shape=[1])
  ...         ])
  >>> model.compile(optimizer='sgd', loss='mean_squared_error')
  >>> model.fit(x, y, epochs=1)
  >>> converter = tf.lite.TFLiteConverter.from_keras_model(model)
  >>> tflite_model = converter.convert()
  
  `tflite_model` can be saved to a file and loaded later, or directly into the
  `Interpreter`. Since TensorFlow Lite pre-plans tensor allocations to optimize
  inference, the user needs to call `allocate_tensors()` before any inference.
  
  >>> interpreter = tf.lite.Interpreter(model_content=tflite_model)
  >>> interpreter.allocate_tensors()  # Needed before execution!
  
  Sample execution:
  
  >>> output = interpreter.get_output_details()[0]  # Model has single output.
  >>> input = interpreter.get_input_details()[0]  # Model has single input.
  >>> input_data = tf.constant(1., shape=[1, 1])
  >>> interpreter.set_tensor(input['index'], input_data)
  >>> interpreter.invoke()
  >>> interpreter.get_tensor(output['index']).shape
  (1, 1)
  
  Use `get_signature_runner()` for a more user-friendly inference API.
class_docstr_tok: ["Interpreter","interface","for","running","TensorFlow","Lite","models",".","Models","obtained","from","`","TfLiteConverter","`","can","be","run","in","Python","with","`","Interpreter","`",".","As","an","example",",","lets","generate","a","simple","Keras","model","and","convert","it","to","TFLite","(","`","TfLiteConverter","`","also","supports","other","input","formats","with","`","from_saved_model","`","and","`","from_concrete_function","`",")",">",">",">","x","=","np.array","(","[","[","1",".","]",",","[","2",".","]","]",")",">",">",">","y","=","np.array","(","[","[","2",".","]",",","[","4",".","]","]",")",">",">",">","model","=","tf.keras.models.Sequential","(","[","...","tf.keras.layers.Dropout","(","0.2",")",",","...","tf.keras.layers.Dense","(","units=1",",","input_shape=","[","1","]",")","...","]",")",">",">",">","model.compile","(","optimizer='sgd","'",",","loss='mean_squared_error","'",")",">",">",">","model.fit","(","x",",","y",",","epochs=1",")",">",">",">","converter","=","tf.lite.TFLiteConverter.from_keras_model","(","model",")",">",">",">","tflite_model","=","converter.convert","(",")","`","tflite_model","`","can","be","saved","to","a","file","and","loaded","later",",","or","directly","into","the","`","Interpreter","`",".","Since","TensorFlow","Lite","pre-plans","tensor","allocations","to","optimize","inference",",","the","user","needs","to","call","`","allocate_tensors","(",")","`","before","any","inference",".",">",">",">","interpreter","=","tf.lite.Interpreter","(","model_content=tflite_model",")",">",">",">","interpreter.allocate_tensors","(",")","#","Needed","before","execution","!","Sample","execution",":",">",">",">","output","=","interpreter.get_output_details","(",")","[","0","]","#","Model","has","single","output",".",">",">",">","input","=","interpreter.get_input_details","(",")","[","0","]","#","Model","has","single","input",".",">",">",">","input_data","=","tf.constant","(","1.",",","shape=","[","1",",","1","]",")",">",">",">","interpreter.set_tensor","(","input","[","'index","'","]",",","input_data",")",">",">",">","interpreter.invoke","(",")",">",">",">","interpreter.get_tensor","(","output","[","'index","'","]",")",".shape","(","1",",","1",")","Use","`","get_signature_runner","(",")","`","for","a","more","user-friendly","inference","API","."]
docstr: Returns function that gives a numpy view of the current tensor buffer.
  
  This allows reading and writing to this tensors w/o copies. This more
  closely mirrors the C++ Interpreter class interface's tensor() member, hence
  the name. Be careful to not hold these output references through calls
  to `allocate_tensors()` and `invoke()`. This function cannot be used to read
  intermediate results.
  
  Usage:
  
  ```
  interpreter.allocate_tensors()
  input = interpreter.tensor(interpreter.get_input_details()[0]["index"])
  output = interpreter.tensor(interpreter.get_output_details()[0]["index"])
  for i in range(10):
    input().fill(3.)
    interpreter.invoke()
    print("inference %s" % output())
  ```
  
  Notice how this function avoids making a numpy array directly. This is
  because it is important to not hold actual numpy views to the data longer
  than necessary. If you do, then the interpreter can no longer be invoked,
  because it is possible the interpreter would resize and invalidate the
  referenced tensors. The NumPy API doesn't allow any mutability of the
  the underlying buffers.
  
  WRONG:
  
  ```
  input = interpreter.tensor(interpreter.get_input_details()[0]["index"])()
  output = interpreter.tensor(interpreter.get_output_details()[0]["index"])()
  interpreter.allocate_tensors()  # This will throw RuntimeError
  for i in range(10):
    input.fill(3.)
    interpreter.invoke()  # this will throw RuntimeError since input,output
  ```
  
  Args:
    tensor_index: Tensor index of tensor to get. This value can be gotten from
      the 'index' field in get_output_details.
  
  Returns:
    A function that can return a new numpy array pointing to the internal
    TFLite tensor state at any point. It is safe to hold the function forever,
    but it is not safe to hold the numpy array forever.
code: def tensor(self, tensor_index):
      """Returns function that gives a numpy view of the current tensor buffer.
  
      This allows reading and writing to this tensors w/o copies. This more
      closely mirrors the C++ Interpreter class interface's tensor() member, hence
      the name. Be careful to not hold these output references through calls
      to `allocate_tensors()` and `invoke()`. This function cannot be used to read
      intermediate results.
  
      Usage:
  
      ```
      interpreter.allocate_tensors()
      input = interpreter.tensor(interpreter.get_input_details()[0]["index"])
      output = interpreter.tensor(interpreter.get_output_details()[0]["index"])
      for i in range(10):
        input().fill(3.)
        interpreter.invoke()
        print("inference %s" % output())
      ```
  
      Notice how this function avoids making a numpy array directly. This is
      because it is important to not hold actual numpy views to the data longer
      than necessary. If you do, then the interpreter can no longer be invoked,
      because it is possible the interpreter would resize and invalidate the
      referenced tensors. The NumPy API doesn't allow any mutability of the
      the underlying buffers.
  
      WRONG:
  
      ```
      input = interpreter.tensor(interpreter.get_input_details()[0]["index"])()
      output = interpreter.tensor(interpreter.get_output_details()[0]["index"])()
      interpreter.allocate_tensors()  # This will throw RuntimeError
      for i in range(10):
        input.fill(3.)
        interpreter.invoke()  # this will throw RuntimeError since input,output
      ```
  
      Args:
        tensor_index: Tensor index of tensor to get. This value can be gotten from
          the 'index' field in get_output_details.
  
      Returns:
        A function that can return a new numpy array pointing to the internal
        TFLite tensor state at any point. It is safe to hold the function forever,
        but it is not safe to hold the numpy array forever.
      """
      return lambda: self._interpreter.tensor(
          self._interpreter, tensor_index
      )
  
imports: import ctypes
  import enum
  import os
  import platform
  import sys
  import numpy
label_desc: Use image node_id 18 for calling the Interpreter obj's underlying member method code with example usage: obj.tensor(tensor_index) and returns: function