# Path: meta_dataset/data/dataset_spec.py
# def get_classes(split, classes_per_split):
# def _check_validity_of_restricted_classes_per_split(
#     restricted_classes_per_split, classes_per_split):
# def get_total_images_per_class(data_spec, class_id=None, pool=None):
#   def __new__(cls, name, image_shape, dataset_spec_list, has_dag_ontology,
#               has_bilevel_ontology, splits_to_contribute):
#   def initialize(self, restricted_classes_per_split=None):
#   def get_total_images_per_class(self, class_id=None, pool=None):
#   def get_classes(self, split):
#   def to_dict(self):
#   def initialize(self, restricted_classes_per_split=None):
#   def get_total_images_per_class(self, class_id=None, pool=None):
#   def get_superclasses(self, split):
#   def _count_classes_in_superclasses(self, superclass_ids):
#   def _get_split_offset(self, split):
#   def get_classes(self, split):
#   def get_class_ids_from_superclass_subclass_inds(self, split, superclass_id,
#                                                   class_inds):
#   def to_dict(self):
#   def initialize(self, restricted_classes_per_split=None):
#   def get_classes_per_split(self):
#     def count_split_classes(split):
#   def get_split_subgraph(self, split):
#   def get_classes(self, split):
#   def get_total_images_per_class(self, class_id, pool=None):
#   def to_dict(self):
# def as_dataset_spec(dct):
#   def _key_to_int(dct):
#   def _key_to_split(dct):
# def load_dataset_spec(dataset_records_path, convert_from_pkl=False):
# class BenchmarkSpecification(
#     collections.namedtuple(
#         'BenchmarkSpecification', 'name, image_shape, dataset_spec_list,'
#         'has_dag_ontology, has_bilevel_ontology, splits_to_contribute')):
# class DatasetSpecification(
#     collections.namedtuple('DatasetSpecification',
#                            ('name, classes_per_split, images_per_class, '
#                             'class_names, path, file_pattern'))):
# class BiLevelDatasetSpecification(
#     collections.namedtuple('BiLevelDatasetSpecification',
#                            ('name, superclasses_per_split, '
#                             'classes_per_superclass, images_per_class, '
#                             'superclass_names, class_names, path, '
#                             'file_pattern'))):
# class HierarchicalDatasetSpecification(
#     collections.namedtuple('HierarchicalDatasetSpecification',
#                            ('name, split_subgraphs, images_per_class, '
#                             'class_names, path, file_pattern'))):


import json
import os
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags
from absl import logging
from meta_dataset.data import dataset_spec as dataset_spec_lib
    example = tf.parse_single_example(example_string, features=features)
    label = example[label_field_name]
    return label

  dataset = dataset.map(_parse_function)
  iterator = dataset.make_one_shot_iterator()
  next_element = iterator.get_next()
  count = 0
  values = set()
  with tf.Session() as sess:
    try:
      while True:
        value = sess.run(next_element)
        count += 1
        values.add(value)
    except tf.errors.OutOfRangeError:
      pass
  return count, values


def main(argv):
  if len(argv) > 1:
    raise app.UsageError('Too many command-line arguments.')

  # Report failed checks as they occur and maintain a counter, instead of
  # raising exceptions right away, so all issues can be reported at once.
  num_failed_checks = 0

  # Load dataset_spec, this should fail if it is absent or incorrect.
  if FLAGS.dataset_spec_file is None:

# Path: meta_dataset/data/dataset_spec.py
# def get_classes(split, classes_per_split):
# def _check_validity_of_restricted_classes_per_split(
#     restricted_classes_per_split, classes_per_split):
# def get_total_images_per_class(data_spec, class_id=None, pool=None):
#   def __new__(cls, name, image_shape, dataset_spec_list, has_dag_ontology,
#               has_bilevel_ontology, splits_to_contribute):
#   def initialize(self, restricted_classes_per_split=None):
#   def get_total_images_per_class(self, class_id=None, pool=None):
#   def get_classes(self, split):
#   def to_dict(self):
#   def initialize(self, restricted_classes_per_split=None):
#   def get_total_images_per_class(self, class_id=None, pool=None):
#   def get_superclasses(self, split):
#   def _count_classes_in_superclasses(self, superclass_ids):
#   def _get_split_offset(self, split):
#   def get_classes(self, split):
#   def get_class_ids_from_superclass_subclass_inds(self, split, superclass_id,
#                                                   class_inds):
#   def to_dict(self):
#   def initialize(self, restricted_classes_per_split=None):
#   def get_classes_per_split(self):
#     def count_split_classes(split):
#   def get_split_subgraph(self, split):
#   def get_classes(self, split):
#   def get_total_images_per_class(self, class_id, pool=None):
#   def to_dict(self):
# def as_dataset_spec(dct):
#   def _key_to_int(dct):
#   def _key_to_split(dct):
# def load_dataset_spec(dataset_records_path, convert_from_pkl=False):
# class BenchmarkSpecification(
#     collections.namedtuple(
#         'BenchmarkSpecification', 'name, image_shape, dataset_spec_list,'
#         'has_dag_ontology, has_bilevel_ontology, splits_to_contribute')):
# class DatasetSpecification(
#     collections.namedtuple('DatasetSpecification',
#                            ('name, classes_per_split, images_per_class, '
#                             'class_names, path, file_pattern'))):
# class BiLevelDatasetSpecification(
#     collections.namedtuple('BiLevelDatasetSpecification',
#                            ('name, superclasses_per_split, '
#                             'classes_per_superclass, images_per_class, '
#                             'superclass_names, class_names, path, '
#                             'file_pattern'))):
# class HierarchicalDatasetSpecification(
#     collections.namedtuple('HierarchicalDatasetSpecification',
#                            ('name, split_subgraphs, images_per_class, '
#                             'class_names, path, file_pattern'))):


# Path: meta_dataset/dataset_conversion/check_dataset_consistency.py
import json
import os
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags
from absl import logging
from meta_dataset.data import dataset_spec as dataset_spec_lib

    example = tf.parse_single_example(example_string, features=features)
    label = example[label_field_name]
    return label

  dataset = dataset.map(_parse_function)
  iterator = dataset.make_one_shot_iterator()
  next_element = iterator.get_next()
  count = 0
  values = set()
  with tf.Session() as sess:
    try:
      while True:
        value = sess.run(next_element)
        count += 1
        values.add(value)
    except tf.errors.OutOfRangeError:
      pass
  return count, values


def main(argv):
  if len(argv) > 1:
    raise app.UsageError('Too many command-line arguments.')

  # Report failed checks as they occur and maintain a counter, instead of
  # raising exceptions right away, so all issues can be reported at once.
  num_failed_checks = 0

  # Load dataset_spec, this should fail if it is absent or incorrect.
  if FLAGS.dataset_spec_file is None:

    dataset_spec = dataset_spec_lib.load_dataset_spec(