code: def _generate_data(split_name, num_examples):
      """Generate test data."""
      names_file = tfds.core.tfds_path(
          os.path.join("image", "dtd_key_attributes.txt")
      )
      label_names = tfds.features.ClassLabel(
          names_file=names_file
      ).names
  
      # Generate images.
      generated_filenames = []
      for n in range(num_examples):
          label = random.choice(label_names)
          fname = "%s/%s_%04d.jpg" % (label, label, n)
          tmp_file_path = fake_data_utils.get_random_jpeg()
          dst_file_path = os.path.join(
              _output_dir(), "dtd", "images", fname
          )
          generated_filenames.append(fname)
  
          _makedir_if_not_exists(os.path.dirname(dst_file_path))
          tf.io.gfile.copy(tmp_file_path, dst_file_path, overwrite=True)
  
      split_path = os.path.join(
          _output_dir(), "dtd", "labels", split_name + ".txt"
      )
      _makedir_if_not_exists(os.path.dirname(split_path))
      with tf.io.gfile.GFile(split_path, "w") as split_file:
          for fname in generated_filenames:
              split_file.write("%s\n" % fname)
  
file_path: datasets/tensorflow_datasets/testing/fake_data_generation/dtd.py
imports: import os
  import random
  from absl import app
  from absl import flags
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  import tensorflow_datasets.public_api
  from tensorflow_datasets.testing import fake_data_utils
label_desc: Use image node_id 3 for calling a global function with example usage: _generate_data(split_name, num_examples) without return types