code: def logical_true_false_random():
      """Return an External Source that returns batch of [True, False, <random booleans>]
      so we always have at least one sample that is True or False.
      Otherwise we may end up with fully short-cutting part of the expression we want to test.
      """
      rng = np.random.default_rng(seed=101)
  
      def get_true_false_random(sample_info):
          if sample_info.idx_in_batch == 0:
              return np.array(True)
          elif sample_info.idx_in_batch == 1:
              return np.array(False)
          else:
              return rng.choice([np.array(True), np.array(False)])
  
      return fn.external_source(
          source=get_true_false_random, batch=False
      )
  
file_path: DALI/dali/test/python/conditionals/test_logical_expressions.py
imports: from nvidia.dali.pipeline import pipeline_def
  import nvidia.dali.fn
  import nvidia.dali.types
  from test_utils import compare_pipelines, check_batch
  from nose_utils import assert_raises
  from nose2.tools import params
  import numpy
label_desc: Use image node_id 7 for calling a global function with example usage: logical_true_false_random() and returns: fn, np, np, rng