code: def test_list_builder_with_empty_elim(ctx_factory):
      from pytest import importorskip
  
      importorskip("mako")
  
      context = ctx_factory()
      queue = cl.CommandQueue(context)
  
      from pyopencl.algorithm import ListOfListsBuilder
  
      builder = ListOfListsBuilder(
          context,
          [
              ("mylist1", np.int32),
              ("mylist2", np.int32),
              ("mylist3", np.int32),
          ],
          """//CL//
              void generate(LIST_ARG_DECL USER_ARG_DECL index_type i)
              {
                  if (i % 5 == 0)
                  {
                      for (int j = 0; j < i / 5; ++j)
                      {
                          APPEND_mylist1(j);
                          APPEND_mylist2(j + 1);
                          APPEND_mylist3(j);
                      }
                  }
              }
          """,
          arg_decls=[],
          eliminate_empty_output_lists=["mylist1", "mylist2"],
      )
  
      result, evt = builder(queue, 1000)
  
      mylist1 = result["mylist1"]
      assert mylist1.count == 19900
      assert (mylist1.starts.get()[:5] == [0, 1, 3, 6, 10]).all()
      assert (
          mylist1.nonempty_indices.get()[:5] == [5, 10, 15, 20, 25]
      ).all()
      assert (mylist1.lists.get()[:6] == [0, 0, 1, 0, 1, 2]).all()
      mylist2 = result["mylist2"]
      assert mylist2.count == 19900
      assert (mylist2.lists.get()[:6] == [1, 1, 2, 1, 2, 3]).all()
      mylist3 = result["mylist3"]
      assert mylist3.count == 19900
      assert (
          mylist3.starts.get()[:10] == [0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
      ).all()
      assert (mylist3.lists.get()[:6] == [0, 0, 1, 0, 1, 2]).all()
  
imports: import numpy
  import numpy.linalg
  import sys
  from pytools import memoize
  from test_array import general_clrand
  import pytest
  import pyopencl
  import pyopencl.array
  from pyopencl.tools import pytest_generate_tests_for_pyopencl
  from pyopencl.characterize import has_double_support, has_struct_arg_count_bug
  from pyopencl.scan import InclusiveScanKernel, ExclusiveScanKernel, GenericScanKernel, GenericDebugScanKernel
  from pyopencl.characterize import get_pocl_version
label_desc: Use image node_id 30 for calling a global function with example usage: test_list_builder_with_empty_elim(ctx_factory) without return types