# Path: libml/models.py
# class CNN13(ClassifySemi):
# class ResNet(ClassifySemi):
# class ShakeNet(ClassifySemi):
# class MultiModel(CNN13, ResNet, ShakeNet):
#     def classifier(self, x, scales, filters, training, getter=None, **kwargs):
#     def classifier(self, x, scales, filters, repeat, training, getter=None, dropout=0, **kwargs):
#         def conv_args(k, f):
#         def residual(x0, filters, stride=1, activate_before_residual=False):
#     def classifier(self, x, scales, filters, repeat, training, getter=None, dropout=0, **kwargs):
#         def conv_args(k, f):
#         def residual(x0, filters, stride=1):
#             def branch():
#     def augment(self, x, l, smoothing, **kwargs):
#     def classifier(self, x, arch, **kwargs):
#     MODELS = ('cnn13', 'resnet', 'shake')
#     MODEL_CNN13, MODEL_RESNET, MODEL_SHAKE = MODELS
# 
# 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 combine_dicts(*args):
# 
# Path: libml/data.py
# PAIR_DATASETS = functools.partial(create_datasets, augment_module.pair_augment_function)
# 
# Path: libml/utils.py
# class EasyDict(dict):
#     def __init__(self, *args, **kwargs):
#         super(EasyDict, self).__init__(*args, **kwargs)
#         self.__dict__ = self


import functools
import os
import tensorflow as tf
from absl import app
from absl import flags
from libml import models, utils
from libml.data import PAIR_DATASETS
from libml.utils import EasyDict
# 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.

"""Mean teachers are better role models:
    Weight-averaged consistency targets improve semi-supervised deep learning results.

Reimplementation of https://arxiv.org/abs/1703.01780
"""



FLAGS = flags.FLAGS



# Path: libml/models.py
# class CNN13(ClassifySemi):
# class ResNet(ClassifySemi):
# class ShakeNet(ClassifySemi):
# class MultiModel(CNN13, ResNet, ShakeNet):
#     def classifier(self, x, scales, filters, training, getter=None, **kwargs):
#     def classifier(self, x, scales, filters, repeat, training, getter=None, dropout=0, **kwargs):
#         def conv_args(k, f):
#         def residual(x0, filters, stride=1, activate_before_residual=False):
#     def classifier(self, x, scales, filters, repeat, training, getter=None, dropout=0, **kwargs):
#         def conv_args(k, f):
#         def residual(x0, filters, stride=1):
#             def branch():
#     def augment(self, x, l, smoothing, **kwargs):
#     def classifier(self, x, arch, **kwargs):
#     MODELS = ('cnn13', 'resnet', 'shake')
#     MODEL_CNN13, MODEL_RESNET, MODEL_SHAKE = MODELS
# 
# 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 combine_dicts(*args):
# 
# Path: libml/data.py
# PAIR_DATASETS = functools.partial(create_datasets, augment_module.pair_augment_function)
# 
# Path: libml/utils.py
# class EasyDict(dict):
#     def __init__(self, *args, **kwargs):
#         super(EasyDict, self).__init__(*args, **kwargs)
#         self.__dict__ = self


# Path: mean_teacher.py
import functools
import os
import tensorflow as tf
from absl import app
from absl import flags
from libml import models, utils
from libml.data import PAIR_DATASETS
from libml.utils import EasyDict

# 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.

"""Mean teachers are better role models:
    Weight-averaged consistency targets improve semi-supervised deep learning results.

Reimplementation of https://arxiv.org/abs/1703.01780
"""



FLAGS = flags.FLAGS



class MeanTeacher(models.MultiModel):