code: def test_example_parser_np():
      features = features_lib.FeaturesDict(
          {
              "feature": features_lib.FeaturesDict(
                  {
                      "nested_text": features_lib.Text(),
                      "nested_float": np.float32,
                  }
              ),
              "array_of_ints": features_lib.Tensor(
                  shape=(2,), dtype=np.int8
              ),
              "array_of_unknown_shape": features_lib.Tensor(
                  shape=(None,), dtype=np.uint16
              ),
              "ragged_tensor": features_lib.Sequence(
                  features_lib.Sequence(
                      features_lib.Tensor(shape=(2,), dtype=np.int32),
                  ),
              ),
              "ragged_tensor_without_length": features_lib.Sequence(
                  features_lib.Sequence(np.str_),
              ),
          }
      )
      serialized_example = tf_example_pb2.Example(
          features=tf_feature_pb2.Features(
              feature={
                  "feature/nested_text": tf_feature_pb2.Feature(
                      bytes_list=tf_feature_pb2.BytesList(
                          value=[b"thisistext"]
                      )
                  ),
                  "feature/nested_float": tf_feature_pb2.Feature(
                      float_list=tf_feature_pb2.FloatList(value=[1.0])
                  ),
                  "array_of_ints": tf_feature_pb2.Feature(
                      int64_list=tf_feature_pb2.Int64List(value=[2, 3])
                  ),
                  "array_of_unknown_shape": tf_feature_pb2.Feature(
                      int64_list=tf_feature_pb2.Int64List(
                          value=[4, 5, 6]
                      )
                  ),
                  "ragged_tensor/ragged_flat_values": tf_feature_pb2.Feature(
                      int64_list=tf_feature_pb2.Int64List(
                          value=[0, 1, 2, 3, 4, 5]
                      )
                  ),
                  "ragged_tensor/ragged_row_lengths_0": tf_feature_pb2.Feature(
                      int64_list=tf_feature_pb2.Int64List(
                          value=[2, 0, 1]
                      )
                  ),
                  "ragged_tensor_without_length/ragged_flat_values": (
                      tf_feature_pb2.Feature(
                          bytes_list=tf_feature_pb2.BytesList(
                              value=[b"abcd", b"efg", b"hij"]
                          )
                      )
                  ),
                  "ragged_tensor_without_length/ragged_row_lengths_0": (
                      tf_feature_pb2.Feature(
                          int64_list=tf_feature_pb2.Int64List(
                              value=[2, 0, 1]
                          )
                      )
                  ),
              }
          )
      ).SerializeToString()
      expected_np = {
          "feature": {
              "nested_text": b"thisistext",
              "nested_float": 1.0,
          },
          "array_of_ints": np.asarray([2, 3], dtype=np.int8),
          "array_of_unknown_shape": np.asarray(
              [4, 5, 6], dtype=np.uint16
          ),
          "ragged_tensor": [
              [[0, 1], [2, 3]],
              [],
              [[4, 5]],
          ],
          "ragged_tensor_without_length": [
              [b"abcd", b"efg"],
              [],
              [b"hij"],
          ],
      }
      example_specs = features.get_tensor_info()
      example_parser_np = example_parser.ExampleParserNp(example_specs)
      parsed_example = example_parser_np.parse_example(
          serialized_example
      )
      assert isinstance(parsed_example["array_of_ints"], np.ndarray)
      assert isinstance(
          parsed_example["array_of_unknown_shape"], np.ndarray
      )
      assert parsed_example["array_of_ints"].dtype == np.int8
      assert parsed_example["array_of_unknown_shape"].dtype == np.uint16
      np.testing.assert_equal(parsed_example, expected_np)
  
file_path: datasets/tensorflow_datasets/core/example_parser_test.py
imports: import numpy
  import pytest
  from tensorflow_datasets.core import example_parser
  from tensorflow_datasets.core import features
  from tensorflow_datasets.proto import tf_example_pb2
  from tensorflow_datasets.proto import tf_feature_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: test_example_parser_np() without return types