code: def testTensorArrayWithCondResetByExternalCaptureBreaks(self):
      if control_flow_v2_toggles.control_flow_v2_enabled():
          self.skipTest("v1 only test")
  
      empty_ta = tensor_array_ops.TensorArray(
          size=0,
          element_shape=[],
          dtype=dtypes.int64,
          dynamic_size=True,
      )
  
      def scan_fn(ta, x):
          updated = ta.write(ta.size(), x)
          # Here, capture empty_ta from outside the function.  However, it may be
          # either a TF1-style TensorArray or an Eager-style TensorArray.
          next_iter = cond.cond(
              math_ops.equal(x % 3, 0),
              lambda: empty_ta,
              lambda: updated,
          )
          return (next_iter, updated.stack())
  
      start = empty_ta
      start = start.write(0, -1)
  
      with self.assertRaisesRegex(
          NotImplementedError,
          r"construct a new TensorArray inside the function",
      ):
          dataset_ops.Dataset.range(6).scan(
              initial_state=start, scan_func=scan_fn
          )
  
imports: import itertools
  from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.kernel_tests import checkpoint_test_base
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import options
  from tensorflow.python.data.ops import scan_op
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import test_ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import control_flow_v2_toggles
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import script_ops
  from tensorflow.python.ops import tensor_array_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 7 for calling the ScanTest obj's underlying member method code with example usage: obj.testTensorArrayWithCondResetByExternalCaptureBreaks() and returns: next_iter,  updated