code: def test_condition_stack():
      test_stack = _conditionals._ConditionStack()
      pred_node = DataNode("PredOp")
      pred_nested = DataNode("PredOp2")
      some_op = DataNode("SomeOp")
      some_nested_op = DataNode("SomeOp2")
  
      # model:
      # if pred_node:
      #     some_op()
      #     if pred_nested:
      #         some_nested_op()
  
      test_stack.register_data_nodes(pred_node)
      test_stack.register_data_nodes(pred_nested)
      # Both visible in global scope
      assert test_stack._find_closest(pred_node) == 0
      assert test_stack._find_closest(pred_nested) == 0
      # First predicate, no splitting required, as this is the first nesting level
      first_level = test_stack.push_predicate(pred_node)
      assert _conditionals._data_node_repr(
          pred_node
      ) == _conditionals._data_node_repr(first_level)
  
      test_stack.track_true_branch()
      test_stack.register_data_nodes(some_op)
      assert test_stack._find_closest(some_op) == 1
  
      assert test_stack._find_closest(pred_nested) == 0
      assert test_stack.stack_depth() == 2
  
      true_split = test_stack._realize_split(pred_nested, 0)
      second_level = test_stack.push_predicate(pred_nested)
      # Second predicate require splitting
      assert _conditionals._data_node_repr(
          true_split
      ) == _conditionals._data_node_repr(second_level)
      test_stack.track_true_branch()
      test_stack.register_data_nodes(some_nested_op)
      assert test_stack._find_closest(some_nested_op) == 2
  
      # It's already on this level
      assert len(test_stack.top().produced) == 1
      preprocessed = test_stack.preprocess_input(some_nested_op)
      assert _conditionals._data_node_repr(
          some_nested_op
      ) == _conditionals._data_node_repr(preprocessed)
      assert len(test_stack.top().produced) == 1
  
      # This one is not
      assert len(test_stack.top().produced) == 1
      preprocessed = test_stack.preprocess_input(some_op)
      assert _conditionals._data_node_repr(
          some_op
      ) != _conditionals._data_node_repr(some_nested_op)
      assert len(test_stack.top().produced) == 2
  
      test_stack.pop()
      test_stack.pop()
      assert len(test_stack.top().produced) == 2
  
imports: from nvidia.dali.pipeline import pipeline_def, experimental
  import nvidia.dali.fn
  import nvidia.dali.types
  from nvidia.dali.types import SampleInfo
  from nvidia.dali import _conditionals
  from nvidia.dali.data_node import DataNode
  import numpy
  import os
  from test_utils import check_batch, compare_pipelines
  from nose_utils import assert_raises
  from test_utils import get_dali_extra_path
  from nose2.tools import params
  import itertools
label_desc: Use image node_id 1 for calling a global function with example usage: test_condition_stack() without return types