code: def test_coco_empty_annotations_pix():
      file_root = os.path.join(
          test_data_root, "db", "coco_dummy", "images"
      )
      train_annotations = os.path.join(
          test_data_root, "db", "coco_dummy", "instances.json"
      )
  
      @pipeline_def(batch_size=1, device_id=0, num_threads=4)
      def coco_pipe():
          _, _, _, masks, ids = fn.readers.coco(
              file_root=file_root,
              annotations_file=train_annotations,
              image_ids=True,
              pixelwise_masks=True,
          )
          return masks, ids
  
      pipe = coco_pipe()
      pipe.build()
      number_of_samples = pipe.epoch_size()
      for k in number_of_samples:
          # there is only one reader
          number_of_samples = number_of_samples[k]
          break
  
      annotations = None
      with open(train_annotations) as file:
          annotations = json.load(file)
  
      anno_mapping = {}
      for elm in annotations["annotations"]:
          image_id = elm["image_id"]
          anno_mapping[image_id] = (
              anno_mapping.get(image_id, False) or "segmentation" in elm
          )
  
      for _ in range(number_of_samples):
          mask, image_ids = pipe.run()
          image_ids = int(image_ids.as_array())
          max_mask = np.max(np.array(mask.as_tensor()))
          assert (
              max_mask != 0
              and image_ids in anno_mapping
              and anno_mapping[image_ids]
          ) or (
              max_mask == 0
              and not (
                  image_ids in anno_mapping and anno_mapping[image_ids]
              )
          )
  
imports: import numpy
  import nvidia.dali.fn
  import os
  import tempfile
  import json
  from nvidia.dali import Pipeline, pipeline_def
  from nose_utils import raises
  from nose2.tools import params
  from test_utils import compare_pipelines, get_dali_extra_path
label_desc: Use image node_id 9 for calling a global function with example usage: test_coco_empty_annotations_pix() and returns: masks,  ids