code: def testBranchIsPruned(self):
      @def_function.function(jit_compile=True)
      def switch_case_test():
          branch_index = array_ops.constant(0)
  
          def f1():
              return array_ops.constant(17)
  
          def f2():
              # Some operations that XLA cannot compile.
              image_ops.decode_image(io_ops.read_file("/tmp/bmp"))
              return array_ops.constant(31)
  
          # This tests that we do not try to compile all branches if the branch
          # index in trivially constant.
          return control_flow_switch_case.switch_case(
              branch_index, branch_fns={0: f1, 1: f2}, default=f2
          )
  
      with ops.device(self.device):
          self.assertEqual(switch_case_test().numpy(), 17)
  
file_path: tensorflow-upstream/tensorflow/compiler/tests/case_test.py
imports: from tensorflow.compiler.tests import xla_test
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_switch_case
  from tensorflow.python.ops import image_ops
  from tensorflow.python.ops import io_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling the CaseTest obj's underlying member method code with example usage: obj.testBranchIsPruned() and returns: control_flow_switch_case, array_ops, array_ops