code: def test_dicts():
      @pipeline_def(
          enable_conditionals=True,
          num_threads=4,
          batch_size=8,
          device_id=0,
      )
      def pipeline():
          pred = fn.external_source(
              source=lambda x: np.array(x.idx_in_batch % 2), batch=False
          )
          if pred:
              out = {"out": np.array(2)}
          else:
              out = {"out": np.array(1)}
          return out["out"]
  
      pipe = pipeline()
      pipe.build()
      (out,) = pipe.run()
      check_batch(out, [i % 2 + 1 for i in range(8)])
  
      @pipeline_def(
          enable_conditionals=True,
          num_threads=4,
          batch_size=8,
          device_id=0,
      )
      def pipeline_op():
          pred = fn.external_source(
              source=lambda x: np.array(x.idx_in_batch % 2), batch=False
          )
          data = types.Constant(np.array(42), device="cpu")
          if pred:
              out = {"out": data - 1}
          else:
              out = {"out": data + 1}
          return out["out"]
  
      pipe_op = pipeline_op()
      pipe_op.build()
      (out,) = pipe_op.run()
      check_batch(out, [41 if i % 2 else 43 for i in range(8)])
  
imports: from nvidia.dali import fn, pipeline_def, types
  import numpy
  from test_utils import check_batch
  from nose_utils import assert_raises
label_desc: Use image node_id 2 for calling a global function with example usage: test_dicts() and returns: out, out