# Path: cta/lib/train.py
# class CTAClassifyFullySupervised(ClassifyFullySupervised, CTAClassifySemi):
#     """Fully-supervised classification."""
# 
#     def train_step(self, train_session, gen_labeled):
#         x = gen_labeled()
#         v = train_session.run([self.ops.classify_op, self.ops.train_op, self.ops.update_step],
#                               feed_dict={self.ops.x: x['probe'],
#                                          self.ops.xt: x['image'],
#                                          self.ops.label: x['label']})
#         self.tmp.step = v[-1]
#         lx = v[0]
#         for p in range(lx.shape[0]):
#             error = lx[p]
#             error[x['label'][p]] -= 1
#             error = np.abs(error).sum()
#             self.augmenter.update_rates(x['policy'][p], 1 - 0.5 * error)
# 
# Path: fully_supervised/lib/data.py
# FLAGS = flags.FLAGS
# DATASETS = create_datasets
# class DataSetsFS(data.DataSets):
#     def creator(cls, name, train_files, test_files, valid, augment, parse_fn=data.record_parse, do_memoize=True,
#                 nclass=10, height=32, width=32, colors=3):
#         def create():
# def augment_function(dataset: str):
# def create_datasets():
# 
# Path: libml/utils.py
# _GPUS = None
# FLAGS = flags.FLAGS
#         _GPUS = tuple([x.name for x in local_device_protos if x.device_type == 'GPU'])
# class EasyDict(dict):
#     def __init__(self, *args, **kwargs):
# def get_config():
# def setup_main():
# def setup_tf():
# def smart_shape(x):
# def ilog2(x):
# def find_latest_checkpoint(dir, glob_term='model.ckpt-*.meta'):
# def get_latest_global_step(dir):
# def get_latest_global_step_in_subdir(dir):
# def getter_ema(ema, getter, name, *args, **kwargs):
# def model_vars(scope=None):
# def gpu(x):
# def get_available_gpus():
# def get_gpu():
# def average_gradients(tower_grads):
# def para_list(fn, *args):
# def para_mean(fn, *args):
# def para_cat(fn, *args):
# def interleave(x, batch):
# def de_interleave(x, batch):
# def combine_dicts(*args):


import os
from absl import app
from absl import flags
from cta.lib.train import CTAClassifyFullySupervised
from fully_supervised.fs_mixup import FSMixup
from fully_supervised.lib import data
from libml import utils
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




FLAGS = flags.FLAGS


class CTAFSMixup(FSMixup, CTAClassifyFullySupervised):
    pass


def main(argv):
    utils.setup_main()
    del argv  # Unused.

# Path: cta/lib/train.py
# class CTAClassifyFullySupervised(ClassifyFullySupervised, CTAClassifySemi):
#     """Fully-supervised classification."""
# 
#     def train_step(self, train_session, gen_labeled):
#         x = gen_labeled()
#         v = train_session.run([self.ops.classify_op, self.ops.train_op, self.ops.update_step],
#                               feed_dict={self.ops.x: x['probe'],
#                                          self.ops.xt: x['image'],
#                                          self.ops.label: x['label']})
#         self.tmp.step = v[-1]
#         lx = v[0]
#         for p in range(lx.shape[0]):
#             error = lx[p]
#             error[x['label'][p]] -= 1
#             error = np.abs(error).sum()
#             self.augmenter.update_rates(x['policy'][p], 1 - 0.5 * error)
# 
# Path: fully_supervised/lib/data.py
# FLAGS = flags.FLAGS
# DATASETS = create_datasets
# class DataSetsFS(data.DataSets):
#     def creator(cls, name, train_files, test_files, valid, augment, parse_fn=data.record_parse, do_memoize=True,
#                 nclass=10, height=32, width=32, colors=3):
#         def create():
# def augment_function(dataset: str):
# def create_datasets():
# 
# Path: libml/utils.py
# _GPUS = None
# FLAGS = flags.FLAGS
#         _GPUS = tuple([x.name for x in local_device_protos if x.device_type == 'GPU'])
# class EasyDict(dict):
#     def __init__(self, *args, **kwargs):
# def get_config():
# def setup_main():
# def setup_tf():
# def smart_shape(x):
# def ilog2(x):
# def find_latest_checkpoint(dir, glob_term='model.ckpt-*.meta'):
# def get_latest_global_step(dir):
# def get_latest_global_step_in_subdir(dir):
# def getter_ema(ema, getter, name, *args, **kwargs):
# def model_vars(scope=None):
# def gpu(x):
# def get_available_gpus():
# def get_gpu():
# def average_gradients(tower_grads):
# def para_list(fn, *args):
# def para_mean(fn, *args):
# def para_cat(fn, *args):
# def interleave(x, batch):
# def de_interleave(x, batch):
# def combine_dicts(*args):


# Path: cta/cta_fsmixup.py
import os
from absl import app
from absl import flags
from cta.lib.train import CTAClassifyFullySupervised
from fully_supervised.fs_mixup import FSMixup
from fully_supervised.lib import data
from libml import utils

# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




FLAGS = flags.FLAGS


class CTAFSMixup(FSMixup, CTAClassifyFullySupervised):
    pass


def main(argv):
    utils.setup_main()
    del argv  # Unused.

    dataset = data.DATASETS()[FLAGS.dataset]()