code: def test_ngram_delta_threshold(
      dataset_0_3_8_10_11_20_23, reader_factory
  ):
      """Test to verify that delta threshold work as expected in one partition in the same ngram
      and between consecutive ngrams. delta threshold here refers that each ngram must not be
      more than delta threshold apart for the field specified by timestamp_field.
      """
  
      fields = {
          0: [
              TestSchema.id,
              TestSchema.id2,
              TestSchema.image_png,
              TestSchema.matrix,
          ],
          1: [TestSchema.id, TestSchema.id2, TestSchema.sensor_name],
      }
      ngram = NGram(
          fields=fields,
          delta_threshold=4,
          timestamp_field=TestSchema.id,
      )
      with reader_factory(
          dataset_0_3_8_10_11_20_23.url,
          schema_fields=ngram,
          shuffle_row_groups=False,
      ) as reader:
          # NGrams expected: (0, 3), (8, 10), (10, 11)
  
          first_item = next(reader)
          expected_ngram = _get_named_tuple_from_ngram(
              ngram, dataset_0_3_8_10_11_20_23.data, 0
          )
          np.testing.assert_equal(first_item, expected_ngram)
  
          second_item = next(reader)
          expected_ngram = _get_named_tuple_from_ngram(
              ngram, dataset_0_3_8_10_11_20_23.data, 3
          )
          np.testing.assert_equal(second_item, expected_ngram)
  
          third_item = next(reader)
          expected_ngram = _get_named_tuple_from_ngram(
              ngram, dataset_0_3_8_10_11_20_23.data, 5
          )
          np.testing.assert_equal(third_item, expected_ngram)
  
          with pytest.raises(StopIteration):
              next(reader)
  
imports: from decimal import Decimal
  import numpy
  import pytest
  import tensorflow.compat.v1
  from unittest import mock
  from petastorm import make_reader
  from petastorm.ngram import NGram
  from petastorm.tests.conftest import SyntheticDataset, maybe_cached_dataset
  from petastorm.tests.test_common import create_test_dataset, TestSchema
  from petastorm.tests.test_tf_utils import create_tf_graph
  from petastorm.tf_utils import tf_tensors
label_desc: Use image node_id 20 for calling a global function with example usage: test_ngram_delta_threshold(dataset_0_3_8_10_11_20_23, reader_factory) without return types