# Path: selfsup/multi/methods/base.py
# class Method:
#     def __init__(self, name, batch_size):
#         self.name = name
#         self.batch_size = batch_size
# 
#     def input_size(self):
#         return 0
# 
#     def batch_loader(self):
#         raise NotImplemented("Abstract base class")
# 
#     def build_network(network, y, phase_test):
#         raise NotImplemented("Abstract base class")
# 
#     @property
#     def basenet_settings():
#         return {}
# 
#     def make_path(self, name, ext, iteration):
#         return f'img/{self.name}_{name}_{iteration}.png'


import selfsup
import tensorflow as tf
import os
import deepdish as dd
import numpy as np
import itertools
import selfsup.jigsaw
from .base import Method
from collections import OrderedDict
    return patches2


class Jigsaw(Method):
    def __init__(self, name, basenet, loader, patch_size=75, size=3,
                 reduce_channels=128, use_scalers=False):
        self.name = name
        self.basenet = basenet
        self._size = size
        self._patch_size = patch_size
        self._loader = loader
        self._reduce_channels = reduce_channels
        if size == 3:
            self._permutations = PERMUTATIONS
        elif size == 2:
            # They are 1-based due to the permutations file
            self._permutations = 1 + np.array(list(itertools.permutations(range(size**2))))
        self._use_scalers = use_scalers

    @property
    def basenet_settings(self):
        return {'convolutional': False}

    def batch(self):
        x, _ = self._loader.batch()
        y = tf.random_uniform([self._loader.batch_size], dtype=tf.int32, maxval=len(self._permutations))
        patches = _make_random_patches(x, y, self._patch_size, self._permutations, size=self._size)

        pad_both = self.basenet.canonical_input_size - self._patch_size
        pad_lo = pad_both // 2

# Path: selfsup/multi/methods/base.py
# class Method:
#     def __init__(self, name, batch_size):
#         self.name = name
#         self.batch_size = batch_size
# 
#     def input_size(self):
#         return 0
# 
#     def batch_loader(self):
#         raise NotImplemented("Abstract base class")
# 
#     def build_network(network, y, phase_test):
#         raise NotImplemented("Abstract base class")
# 
#     @property
#     def basenet_settings():
#         return {}
# 
#     def make_path(self, name, ext, iteration):
#         return f'img/{self.name}_{name}_{iteration}.png'


# Path: selfsup/multi/methods/jigsaw.py
import selfsup
import tensorflow as tf
import os
import deepdish as dd
import numpy as np
import itertools
import selfsup.jigsaw
from .base import Method
from collections import OrderedDict

    return patches2


class Jigsaw(Method):
    def __init__(self, name, basenet, loader, patch_size=75, size=3,
                 reduce_channels=128, use_scalers=False):
        self.name = name
        self.basenet = basenet
        self._size = size
        self._patch_size = patch_size
        self._loader = loader
        self._reduce_channels = reduce_channels
        if size == 3:
            self._permutations = PERMUTATIONS
        elif size == 2:
            # They are 1-based due to the permutations file
            self._permutations = 1 + np.array(list(itertools.permutations(range(size**2))))
        self._use_scalers = use_scalers

    @property
    def basenet_settings(self):
        return {'convolutional': False}

    def batch(self):
        x, _ = self._loader.batch()
        y = tf.random_uniform([self._loader.batch_size], dtype=tf.int32, maxval=len(self._permutations))
        patches = _make_random_patches(x, y, self._patch_size, self._permutations, size=self._size)

        pad_both = self.basenet.canonical_input_size - self._patch_size
        pad_lo = pad_both // 2

        pad_up = pad_both - pad_lo