code: def test_debayer_per_sample_pattern(self, batch_size, dtype):
      num_iterations = 3
      num_patterns = len(bayer_patterns)
      rng = np.random.default_rng(seed=42 + batch_size)
      bayered_imgs, npp_baseline = self.get_test_data(dtype)
  
      def source(sample_info):
          idx = sample_info.idx_in_epoch % self.num_samples
          pattern_idx = np.int32(rng.uniform(0, num_patterns))
          pattern = bayer_patterns[pattern_idx]
          return (
              bayered_imgs[pattern][idx],
              np.array(blue_position(pattern), dtype=np.int32),
              np.array(idx, dtype=np.int32),
          )
  
      @pipeline_def
      def debayer_pipeline():
          bayer_imgs, blue_poses, idxs = fn.external_source(
              source=source, batch=False, num_outputs=3
          )
          debayered_imgs = fn.experimental.debayer(
              bayer_imgs.gpu(), blue_position=blue_poses
          )
          return debayered_imgs, blue_poses, idxs
  
      pipe = debayer_pipeline(
          batch_size=batch_size, device_id=0, num_threads=4
      )
      pipe.build()
  
      out_batches = []
      for _ in range(num_iterations):
          debayered_imgs_dev, blue_poses, idxs = pipe.run()
          assert debayered_imgs_dev.layout() == "HWC"
          out_batches.append(
              (
                  [
                      np.array(img)
                      for img in debayered_imgs_dev.as_cpu()
                  ],
                  [
                      blue_position2pattern(np.array(blue_pos))
                      for blue_pos in blue_poses
                  ],
                  [np.array(idx) for idx in idxs],
              )
          )
  
      for debayered_imgs, patterns, idxs in out_batches:
          assert len(debayered_imgs) == len(patterns) == len(idxs)
          for img_debayered, pattern, idx in zip(
              debayered_imgs, patterns, idxs
          ):
              baseline = npp_baseline[pattern][idx]
              assert np.all(img_debayered == baseline)
  
imports: import itertools
  import os
  import unittest
  import numpy
  from nvidia.dali import pipeline_def, fn, types
  from test_utils import get_dali_extra_path
  from nose_utils import assert_raises
  from nose2.tools import params
  from debayer_test_utils import bayer_patterns, blue_position, blue_position2pattern, rgb2bayer, rgb2bayer_seq, debayer_bilinear_npp_pattern, debayer_bilinear_npp_pattern_seq
label_desc: Use image node_id 4 for calling the DebayerTest obj's underlying member method code with example usage: obj.test_debayer_per_sample_pattern(batch_size, dtype) and returns: bayered_imgs,  np,  np, debayered_imgs,  blue_poses,  idxs