# Path: weakly_supervised_control/vae/conv_vae.py
# class VAE(ConvVAE):
#     def __init__(
#             self,
#             x_shape: List[int],
#             representation_size: int,
#             init_w: float = 1e-3,
#             num_factors: int = None,
#             **kwargs
#     ):
#     def predict_factors(self, input):
#     def prediction_loss(self, pred, labels):
#     def forward(self, input, predict_factors=False):


from os import path as osp
from torchvision.utils import save_image
from multiworld.core.image_env import normalize_image
from rlkit.core import logger
from rlkit.torch import pytorch_util as ptu
from rlkit.torch.vae.vae_trainer import ConvVAETrainer
from weakly_supervised_control.vae.conv_vae import ConvVAE
import numpy as np
import torch
# Copyright 2020 The Weakly-Supervised Control Authors.
#
# 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
#
#     http://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.
# from collections import OrderedDict




class VAETrainer(ConvVAETrainer):
    def __init__(
            self,

# Path: weakly_supervised_control/vae/conv_vae.py
# class VAE(ConvVAE):
#     def __init__(
#             self,
#             x_shape: List[int],
#             representation_size: int,
#             init_w: float = 1e-3,
#             num_factors: int = None,
#             **kwargs
#     ):
#     def predict_factors(self, input):
#     def prediction_loss(self, pred, labels):
#     def forward(self, input, predict_factors=False):


# Path: weakly_supervised_control/vae/vae_trainer.py
from os import path as osp
from torchvision.utils import save_image
from multiworld.core.image_env import normalize_image
from rlkit.core import logger
from rlkit.torch import pytorch_util as ptu
from rlkit.torch.vae.vae_trainer import ConvVAETrainer
from weakly_supervised_control.vae.conv_vae import ConvVAE
import numpy as np
import torch

# Copyright 2020 The Weakly-Supervised Control Authors.
#
# 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
#
#     http://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.
# from collections import OrderedDict




class VAETrainer(ConvVAETrainer):
    def __init__(
            self,

            model: ConvVAE,