# 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/data/imagenet_specification.py
# FLAGS = tf.flags.FLAGS
# class Synset(object):
#   def __init__(self, wn_id, words, children, parents):
# def get_node_ancestors(synset):
# def get_ancestors(synsets):
# def isolate_graph(nodes):
# def isolate_node(node):
# def collapse(nodes):
#   def collapse_once(nodes):
# def get_leaves(nodes):
# def get_synsets_from_ids(wn_ids, synsets):
# def get_spanning_leaves(nodes):
# def get_num_spanning_images(spanning_leaves, num_leaf_images):
# def create_sampling_graph(synsets, root=None):
# def propose_valid_test_roots(spanning_leaves,
#                              margin=50,
#                              desired_num_valid_classes=150,
#                              desired_num_test_classes=150):
#   def _sort_key(synset_and_leaves):
# def get_class_splits(spanning_leaves, valid_test_roots=None, **kwargs):
# def init_split_subgraphs(class_splits, spanning_leaves, valid_test_roots):
# def copy_graph(nodes, root_wn_id=None):
# def create_splits(spanning_leaves, split_enum, valid_test_roots=None, **kwargs):
# def get_synset_by_wnid(wnid, graph):
# def is_descendent(d, a):
# def get_upward_paths_from(start, end=None):
#   def is_end_node(n):
# def find_lowest_common_in_paths(path_a, path_b):
# def get_lowest_common_ancestor(leaf_a, leaf_b, path='longest'):
# def get_num_synset_2012_images(path, synsets_2012, files_to_skip=None):
# def export_graph(nodes):
# def import_graph(node_representations):
# def create_imagenet_specification(split_enum,
#                                   files_to_skip,
#                                   path_to_num_leaf_images=None,
#                                   train_split_only=False,
#                                   log_stats=True):


from absl import logging
from meta_dataset.data import dataset_spec as dataset_spec_lib
from meta_dataset.data import imagenet_specification
from six.moves import zip
import numpy as np
                  self.num_filtered_classes, self.min_examples_in_class,
                  self.num_classes))

    if self.use_all_classes:
      if self.num_classes != self.num_filtered_classes:
        raise ValueError('"use_all_classes" is not compatible with a value of '
                         '"min_examples_in_class" ({}) that results in some '
                         'classes being excluded.'.format(
                             self.min_examples_in_class))
      self.num_ways = self.num_classes

    # Maybe overwrite use_dag_hierarchy or use_bilevel_hierarchy if requested.
    if episode_descr_config.ignore_dag_ontology:
      self.use_dag_hierarchy = False
    if episode_descr_config.ignore_bilevel_ontology:
      self.use_bilevel_hierarchy = False

    # For Omniglot.
    if self.use_bilevel_hierarchy:
      if self.num_ways is not None:
        raise ValueError('"use_bilevel_hierarchy" is incompatible with '
                         '"num_ways".')
      if self.min_examples_in_class > 0:
        raise ValueError('"use_bilevel_hierarchy" is incompatible with '
                         '"min_examples_in_class".')
      if self.use_dag_hierarchy:
        raise ValueError('"use_bilevel_hierarchy" is incompatible with '
                         '"use_dag_hierarchy".')

      if not isinstance(dataset_spec,

# 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/data/imagenet_specification.py
# FLAGS = tf.flags.FLAGS
# class Synset(object):
#   def __init__(self, wn_id, words, children, parents):
# def get_node_ancestors(synset):
# def get_ancestors(synsets):
# def isolate_graph(nodes):
# def isolate_node(node):
# def collapse(nodes):
#   def collapse_once(nodes):
# def get_leaves(nodes):
# def get_synsets_from_ids(wn_ids, synsets):
# def get_spanning_leaves(nodes):
# def get_num_spanning_images(spanning_leaves, num_leaf_images):
# def create_sampling_graph(synsets, root=None):
# def propose_valid_test_roots(spanning_leaves,
#                              margin=50,
#                              desired_num_valid_classes=150,
#                              desired_num_test_classes=150):
#   def _sort_key(synset_and_leaves):
# def get_class_splits(spanning_leaves, valid_test_roots=None, **kwargs):
# def init_split_subgraphs(class_splits, spanning_leaves, valid_test_roots):
# def copy_graph(nodes, root_wn_id=None):
# def create_splits(spanning_leaves, split_enum, valid_test_roots=None, **kwargs):
# def get_synset_by_wnid(wnid, graph):
# def is_descendent(d, a):
# def get_upward_paths_from(start, end=None):
#   def is_end_node(n):
# def find_lowest_common_in_paths(path_a, path_b):
# def get_lowest_common_ancestor(leaf_a, leaf_b, path='longest'):
# def get_num_synset_2012_images(path, synsets_2012, files_to_skip=None):
# def export_graph(nodes):
# def import_graph(node_representations):
# def create_imagenet_specification(split_enum,
#                                   files_to_skip,
#                                   path_to_num_leaf_images=None,
#                                   train_split_only=False,
#                                   log_stats=True):


# Path: meta_dataset/data/sampling.py
from absl import logging
from meta_dataset.data import dataset_spec as dataset_spec_lib
from meta_dataset.data import imagenet_specification
from six.moves import zip
import numpy as np

                  self.num_filtered_classes, self.min_examples_in_class,
                  self.num_classes))

    if self.use_all_classes:
      if self.num_classes != self.num_filtered_classes:
        raise ValueError('"use_all_classes" is not compatible with a value of '
                         '"min_examples_in_class" ({}) that results in some '
                         'classes being excluded.'.format(
                             self.min_examples_in_class))
      self.num_ways = self.num_classes

    # Maybe overwrite use_dag_hierarchy or use_bilevel_hierarchy if requested.
    if episode_descr_config.ignore_dag_ontology:
      self.use_dag_hierarchy = False
    if episode_descr_config.ignore_bilevel_ontology:
      self.use_bilevel_hierarchy = False

    # For Omniglot.
    if self.use_bilevel_hierarchy:
      if self.num_ways is not None:
        raise ValueError('"use_bilevel_hierarchy" is incompatible with '
                         '"num_ways".')
      if self.min_examples_in_class > 0:
        raise ValueError('"use_bilevel_hierarchy" is incompatible with '
                         '"min_examples_in_class".')
      if self.use_dag_hierarchy:
        raise ValueError('"use_bilevel_hierarchy" is incompatible with '
                         '"use_dag_hierarchy".')

      if not isinstance(dataset_spec,

                        dataset_spec_lib.BiLevelDatasetSpecification):