code: def test_builder_from_directory(
      code_builder: dataset_builder.DatasetBuilder,
  ):
      """Builder can be created from the files only."""
  
      # Reconstruct the dataset
      builder = read_only_builder.builder_from_directory(
          code_builder.data_dir
      )
      assert builder.name == code_builder.name
      assert builder.data_dir == code_builder.data_dir
      assert builder.info.version == code_builder.info.version
      assert builder.info.full_name == code_builder.info.full_name
      assert repr(builder.info) == repr(code_builder.info)
      assert builder.VERSION == code_builder.info.version
      assert builder.RELEASE_NOTES == code_builder.info.release_notes
      assert builder.__module__ == type(code_builder).__module__
      assert read_only_builder.ReadOnlyBuilder.VERSION is None
  
      if code_builder.builder_config:
          assert builder.builder_config
          code_config = code_builder.builder_config
          file_config = builder.builder_config
          # Config attributes should be restored too
          assert code_config.name == file_config.name
          assert code_config.description == file_config.description
          assert code_config.version == file_config.version
  
      # Test that the dataset can be read
      ds = dataset_utils.as_numpy(
          builder.as_dataset(split="train").take(5)
      )
      origin_ds = dataset_utils.as_numpy(
          builder.as_dataset(split="train").take(5)
      )
      assert [ex["id"] for ex in ds] == [ex["id"] for ex in origin_ds]
  
      builder.download_and_prepare()  # Should be a no-op
  
      # Test pickling and un-pickling
      builder2 = dill.loads(dill.dumps(builder))
      assert builder.name == builder2.name
      assert builder.version == builder2.version
  
imports: import contextlib
  import functools
  import os
  import pathlib
  import re
  from typing import Sequence
  from unittest import mock
  import dill
  from etils import epath
  import pytest
  import tensorflow
  from tensorflow_datasets import testing
  from tensorflow_datasets.core import constants
  from tensorflow_datasets.core import dataset_builder
  from tensorflow_datasets.core import dataset_utils
  from tensorflow_datasets.core import load
  from tensorflow_datasets.core import proto
  from tensorflow_datasets.core import read_only_builder
  from tensorflow_datasets.core import registered
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.features import features_dict
  from tensorflow_datasets.core.proto import dataset_info_pb2
  from tensorflow_datasets.core.utils import error_utils
  from tensorflow_datasets.core.utils import file_utils
  from google.protobuf import json_format
label_desc: Use image node_id 5 for calling a global function with example usage: test_builder_from_directory(code_builder) without return types