docstr: Python implementation of interleave used for testing.
docstr_tok: ["Python","implementation","of","interleave","used","for","testing","."]
code: def _interleave(self, lists, cycle_length, block_length):
      """Python implementation of interleave used for testing."""
      num_open = 0
  
      # `all_iterators` acts as a queue of iterators over each element of `lists`.
      all_iterators = [iter(l) for l in lists]
  
      # `open_iterators` are the iterators whose elements are currently being
      # interleaved.
      open_iterators = []
      for i in range(cycle_length):
          if all_iterators:
              open_iterators.append(all_iterators.pop(0))
              num_open += 1
          else:
              open_iterators.append(None)
  
      while num_open or all_iterators:
          for i in range(cycle_length):
              if open_iterators[i] is None:
                  if all_iterators:
                      open_iterators[i] = all_iterators.pop(0)
                      num_open += 1
                  else:
                      continue
              for _ in range(block_length):
                  try:
                      yield next(open_iterators[i])
                  except StopIteration:
                      open_iterators[i] = None
                      num_open -= 1
                      break
  
imports: import itertools
  import math
  import threading
  import time
  from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.experimental.ops import interleave_ops
  from tensorflow.python.data.experimental.ops import testing
  from tensorflow.python.data.kernel_tests import checkpoint_test_base
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import options
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import script_ops
  from tensorflow.python.ops import sparse_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 3 for calling the ParallelInterleaveTest obj's underlying member method code with example usage: obj._interleave(lists, cycle_length, block_length) without return types