code: def test_dataset_info_from_proto(
      generator_builder,
  ):  # pylint: disable=redefined-outer-name
      train = dataset_info_pb2.SplitInfo(
          name="train", num_shards=2, shard_lengths=[4, 5]
      )
      test = dataset_info_pb2.SplitInfo(
          name="test", num_shards=3, shard_lengths=[1, 2, 3]
      )
      text_feature = feature_pb2.Feature(
          python_class_name="tensorflow_datasets.core.features.text_feature.Text",
          text=feature_pb2.TextFeature(),
      )
      proto = dataset_info_pb2.DatasetInfo(
          name="random_shaped_image_generator",
          config_name=generator_builder.builder_config.name,
          version=str(generator_builder.version),
          features=feature_pb2.Feature(
              python_class_name=(
                  "tensorflow_datasets.core.features.features_dict.FeaturesDict"
              ),
              features_dict=feature_pb2.FeaturesDict(
                  features={"text": text_feature}
              ),
          ),
          splits=[train, test],
      )
      result = dataset_info.DatasetInfo.from_proto(
          builder=generator_builder,
          proto=proto,
      )
      assert result.splits["test"].shard_lengths == test.shard_lengths
      assert result.splits["train"].shard_lengths == train.shard_lengths
      assert set(result.features.keys()) == {"text"}
      assert result.version == generator_builder.version
  
imports: import json
  import os
  import pathlib
  import tempfile
  import time
  from typing import Union
  import numpy
  import pytest
  import tensorflow
  from tensorflow_datasets import testing
  from tensorflow_datasets.core import dataset_builder
  from tensorflow_datasets.core import dataset_info
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import read_only_builder
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.proto import dataset_info_pb2
  from tensorflow_datasets.core.proto import feature_pb2
  from tensorflow_datasets.image_classification import mnist
  from tensorflow_datasets.testing.dummy_config_based_datasets.dummy_ds_1 import dummy_ds_1_dataset_builder
  from google.protobuf import text_format
label_desc: Use image node_id 4 for calling a global function with example usage: test_dataset_info_from_proto(generator_builder) without return types