code: def test_ngram_validation():
      """Test to verify that ngram validation work as expected."""
  
      fields = {
          0: [
              TestSchema.id,
              TestSchema.id2,
              TestSchema.image_png,
              TestSchema.matrix,
          ],
          1: [TestSchema.id, TestSchema.id2, TestSchema.sensor_name],
      }
  
      with pytest.raises(ValueError):
          # delta threshold must be an int
          NGram(
              fields=fields,
              delta_threshold="abc",
              timestamp_field=TestSchema.id,
          )
  
      with pytest.raises(ValueError):
          # timestamp_field must be a field
          NGram(fields=fields, delta_threshold=5, timestamp_field=5)
  
      with pytest.raises(ValueError):
          # Fields must be a dict
          NGram(
              fields=[],
              delta_threshold=5,
              timestamp_field=TestSchema.id,
          )
  
      with pytest.raises(ValueError):
          # Each value in fields must be an array
          NGram(
              fields={0: "test"},
              delta_threshold=5,
              timestamp_field=TestSchema.id,
          )
  
      with pytest.raises(ValueError):
          # timestamp_overlap must be bool
          NGram(
              fields=fields,
              delta_threshold=0.5,
              timestamp_field=TestSchema.id,
              timestamp_overlap=2,
          )
  
      # Check some positive cases
      NGram(
          fields=fields,
          delta_threshold=0.5,
          timestamp_field=TestSchema.id,
      )
      NGram(
          fields=fields,
          delta_threshold=Decimal("0.5"),
          timestamp_field=TestSchema.id,
      )
  
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 23 for calling a global function with example usage: test_ngram_validation() without return types