Have you checked the internal test:

  

      github.com
  

  
    tensorflow/tensorflow/blob/master/tensorflow/lite/python/interpreter_test.py#L388 1



      
      
            self.assertTrue(self.interpreter._safe_to_run())
            in0 = self.interpreter.tensor(self.input0)()
            self.assertFalse(self.interpreter._safe_to_run())
            in0b = self.interpreter.tensor(self.input0)()
            self.assertFalse(self.interpreter._safe_to_run())
            # Now get rid of the buffers so that we can evaluate.
            del in0
            del in0b
            self.assertTrue(self.interpreter._safe_to_run())
          
          def testBaseProtectsFunctions(self):
            in0 = self.interpreter.tensor(self.input0)()
            # Make sure we get an exception if we try to run an unsafe operation
            with self.assertRaisesRegex(RuntimeError, 'There is at least 1 reference'):
              _ = self.interpreter.allocate_tensors()
            # Make sure we get an exception if we try to run an unsafe operation
            with self.assertRaisesRegex(RuntimeError, 'There is at least 1 reference'):
              _ = self.interpreter.invoke()  # pylint: disable=assignment-from-no-return
            # Now test that we can run
            del in0  # this is our only buffer reference, so now it is safe to change
            in0safe = self.interpreter.tensor(self.input0)