code: def testConstantFoldingVarLenFeature(self):
      example = example_pb2.Example(
          features=feature_pb2.Features(feature={})
      )
      dataset = dataset_ops.Dataset.from_tensors(
          example.SerializeToString()
      )
  
      def parse_fn(serialized):
          features = {"x": parsing_ops.VarLenFeature(dtypes.int64)}
          parsed = parsing_ops.parse_single_example(
              serialized, features
          )
          parsed = parsed["x"].values
  
          size = array_ops.size(parsed)
          value = math_ops.cast(parsed, dtypes.bool)
          return cond.cond(
              size > 0,
              lambda: array_ops.reshape(value, []),
              lambda: array_ops.zeros([], dtypes.bool),
          )
  
      dataset = dataset.map(parse_fn)
  
      self.assertDatasetProduces(dataset, expected_output=[0])
  
file_path: tensorflow-upstream/tensorflow/python/data/experimental/kernel_tests/optimization/grappler_test.py
imports: from absl.testing import parameterized
  from tensorflow.core.example import example_pb2
  from tensorflow.core.example import feature_pb2
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import dtypes
  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 math_ops
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.ops import parsing_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 1 for calling the GrapplerTest obj's underlying member method code with example usage: obj.testConstantFoldingVarLenFeature() and returns: cond