# Path: morph_net/framework/concat_and_slice_regularizers.py
# class ConcatRegularizer(generic_regularizers.OpRegularizer):
# class SlicingReferenceRegularizer(generic_regularizers.OpRegularizer):
#   def __init__(self, regularizers_to_concatenate):
#   def regularization_vector(self):
#   def alive_vector(self):
#   def __init__(self, get_regularizer_to_slice, begin, size):
#   def regularization_vector(self):
#   def alive_vector(self):
# 
# Path: morph_net/testing/op_regularizer_stub.py
# class OpRegularizerStub(generic_regularizers.OpRegularizer):
# class OpRegularizerStubFactory(object):
#   def __init__(self, regularization_vector, alive_vector):
#   def regularization_vector(self):
#   def alive_vector(self):
#   def __init__(self, alive_stub_dict, reg_stub_dict):
#   def _create_stub(self, key):
#   def create_conv2d_regularizer(self, conv_op, manager=None):
# def image_stub():


from morph_net.framework import concat_and_slice_regularizers
from morph_net.testing import op_regularizer_stub
import tensorflow.compat.v1 as tf

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function



class ConcatAndSliceRegularizersTest(tf.test.TestCase):

  def setUp(self):
    super(ConcatAndSliceRegularizersTest, self).setUp()
    self._reg_vec1 = [0.1, 0.3, 0.6, 0.2]
    self._alive_vec1 = [False, True, True, False]
    self._reg_vec2 = [0.2, 0.4, 0.5]
    self._alive_vec2 = [False, True, False]
    self._reg1 = op_regularizer_stub.OpRegularizerStub(self._reg_vec1,
                                                       self._alive_vec1)
    self._reg2 = op_regularizer_stub.OpRegularizerStub(self._reg_vec2,
                                                       self._alive_vec2)

  def testConcatRegularizer(self):
    concat_reg = concat_and_slice_regularizers.ConcatRegularizer(
        [self._reg1, self._reg2])
    with self.cached_session():
      self.assertAllEqual(self._alive_vec1 + self._alive_vec2,
                          concat_reg.alive_vector.eval())
      self.assertAllClose(self._reg_vec1 + self._reg_vec2,
                          concat_reg.regularization_vector.eval(), 1e-5)

  def testSliceRegularizer(self):

# Path: morph_net/framework/concat_and_slice_regularizers.py
# class ConcatRegularizer(generic_regularizers.OpRegularizer):
# class SlicingReferenceRegularizer(generic_regularizers.OpRegularizer):
#   def __init__(self, regularizers_to_concatenate):
#   def regularization_vector(self):
#   def alive_vector(self):
#   def __init__(self, get_regularizer_to_slice, begin, size):
#   def regularization_vector(self):
#   def alive_vector(self):
# 
# Path: morph_net/testing/op_regularizer_stub.py
# class OpRegularizerStub(generic_regularizers.OpRegularizer):
# class OpRegularizerStubFactory(object):
#   def __init__(self, regularization_vector, alive_vector):
#   def regularization_vector(self):
#   def alive_vector(self):
#   def __init__(self, alive_stub_dict, reg_stub_dict):
#   def _create_stub(self, key):
#   def create_conv2d_regularizer(self, conv_op, manager=None):
# def image_stub():


# Path: morph_net/framework/concat_and_slice_regularizers_test.py
from morph_net.framework import concat_and_slice_regularizers
from morph_net.testing import op_regularizer_stub
import tensorflow.compat.v1 as tf


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function



class ConcatAndSliceRegularizersTest(tf.test.TestCase):

  def setUp(self):
    super(ConcatAndSliceRegularizersTest, self).setUp()
    self._reg_vec1 = [0.1, 0.3, 0.6, 0.2]
    self._alive_vec1 = [False, True, True, False]
    self._reg_vec2 = [0.2, 0.4, 0.5]
    self._alive_vec2 = [False, True, False]
    self._reg1 = op_regularizer_stub.OpRegularizerStub(self._reg_vec1,
                                                       self._alive_vec1)
    self._reg2 = op_regularizer_stub.OpRegularizerStub(self._reg_vec2,
                                                       self._alive_vec2)

  def testConcatRegularizer(self):
    concat_reg = concat_and_slice_regularizers.ConcatRegularizer(
        [self._reg1, self._reg2])
    with self.cached_session():
      self.assertAllEqual(self._alive_vec1 + self._alive_vec2,
                          concat_reg.alive_vector.eval())
      self.assertAllClose(self._reg_vec1 + self._reg_vec2,
                          concat_reg.regularization_vector.eval(), 1e-5)

  def testSliceRegularizer(self):

    concat_reg = concat_and_slice_regularizers.SlicingReferenceRegularizer(