code: def testFunctionError(self):
      # In this test we verify that a function that raises an error ends up
      # properly deallocating the iterator resource.
  
      queue = data_flow_ops.FIFOQueue(10, dtypes.int64)
      queue.enqueue(0)
  
      def init_fn(n):
          return n
  
      def next_fn(_):
          ds = dataset_ops.Dataset.range(0)
          return next(iter(ds))
  
      def finalize_fn(n):
          queue.enqueue(0)
          return n
  
      @def_function.function
      def fn():
          dataset = from_generator_op._GeneratorDataset(
              1,
              init_fn,
              next_fn,
              finalize_fn,
              output_signature=tensor_spec.TensorSpec([], dtypes.int64),
          )
          iterator = multi_device_iterator_ops.OwnedMultiDeviceIterator(
              dataset, [self._devices[1], self._devices[2]]
          )
          next(iterator)
  
      with self.assertRaises(errors.OutOfRangeError):
          fn()
  
      self.assertEqual(queue.size().numpy(), 2)
  
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.experimental.ops import testing
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import from_generator_op
  from tensorflow.python.data.ops import multi_device_iterator_ops
  from tensorflow.python.data.ops import options
  from tensorflow.python.eager import cancellation
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.eager import executor
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.ops import data_flow_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 4 for calling the OwnedMultiDeviceIteratorTest obj's underlying member method code with example usage: obj.testFunctionError() and returns: n, next, n