docstr: Tests that default optimizations are disabled with ref variables.
docstr_tok: ["Tests","that","default","optimizations","are","disabled","with","ref","variables","."]
code: def testOptimizationWithCapturedRefVar(self, dataset_fn):
      """Tests that default optimizations are disabled with ref variables."""
      variable = variable_scope.get_variable(
          "v", initializer=0, use_resource=False
      )
      assign_op = variable.assign_add(1)
      unoptimized_dataset = dataset_fn(variable)
  
      options = options_lib.Options()
      options.experimental_optimization.apply_default_optimizations = (
          False
      )
      options.experimental_optimization.noop_elimination = True
      options.experimental_optimization.map_and_batch_fusion = True
      options.experimental_warm_start = False
      optimized_dataset = unoptimized_dataset.with_options(options)
      optimized_it = dataset_ops.make_initializable_iterator(
          optimized_dataset
      )
  
      # Check that outputs are the same in the optimized and unoptimized cases,
      # when the variable value is changing.
      unoptimized_it = dataset_ops.make_initializable_iterator(
          unoptimized_dataset
      )
      with ops.control_dependencies([assign_op]):
          unoptimized_output = unoptimized_it.get_next()
          optimized_output = optimized_it.get_next()
  
      self.evaluate(variable.initializer)
      self.evaluate(
          (unoptimized_it.initializer, optimized_it.initializer)
      )
      while True:
          try:
              unoptimized, optimized = self.evaluate(
                  (unoptimized_output, optimized_output)
              )
              self.assertEqual(unoptimized, optimized)
          except errors.OutOfRangeError:
              break
  
imports: import functools
  import time
  from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.experimental.ops import batching
  from tensorflow.python.data.experimental.ops import grouping
  from tensorflow.python.data.experimental.ops import scan_ops
  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 options
  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.ops import array_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 8 for calling the OptimizationTest obj's underlying member method code with example usage: obj.testOptimizationWithCapturedRefVar(dataset_fn) without return types