# Path: morph_net/framework/grouping_regularizers.py
# DEFAULT_THRESHOLD = 0.01
# class MaxGroupingRegularizer(generic_regularizers.OpRegularizer):
# class L2GroupingRegularizer(generic_regularizers.OpRegularizer):
#   def __init__(self, regularizers_to_group):
#   def regularization_vector(self):
#   def alive_vector(self):
#   def __init__(self, regularizers_to_group, threshold=DEFAULT_THRESHOLD):
#   def regularization_vector(self):
#   def alive_vector(self):
# def lazy_square(tensor):
# 
# 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 absl.testing import parameterized
from morph_net.framework import grouping_regularizers
from morph_net.testing import op_regularizer_stub
import numpy as np
import tensorflow.compat.v1 as tf
    with self.cached_session():
      self.assertAllEqual([x > 0.25 for x in expcted_reg_vec],
                          group_reg.alive_vector.eval())
      self.assertAllClose(expcted_reg_vec,
                          group_reg.regularization_vector.eval(), 1e-5)

  @parameterized.named_parameters(
      ('Max', grouping_regularizers.MaxGroupingRegularizer),
      ('L2', _l2_reg_with_025_threshold))
  def testOrderDoesNotMatter(self, create_reg):
    group12 = create_reg([self._reg1, self._reg2])
    group13 = create_reg([self._reg1, self._reg3])
    group23 = create_reg([self._reg2, self._reg3])

    group123 = create_reg([group12, self._reg3])
    group132 = create_reg([group13, self._reg2])
    group231 = create_reg([group23, self._reg1])

    with self.cached_session():
      self.assertAllEqual(group123.alive_vector.eval(),
                          group132.alive_vector.eval())
      self.assertAllEqual(group123.alive_vector.eval(),
                          group231.alive_vector.eval())

      self.assertAllClose(group123.regularization_vector.eval(),
                          group132.regularization_vector.eval())
      self.assertAllClose(group123.regularization_vector.eval(),
                          group231.regularization_vector.eval())

  @parameterized.named_parameters(

# Path: morph_net/framework/grouping_regularizers.py
# DEFAULT_THRESHOLD = 0.01
# class MaxGroupingRegularizer(generic_regularizers.OpRegularizer):
# class L2GroupingRegularizer(generic_regularizers.OpRegularizer):
#   def __init__(self, regularizers_to_group):
#   def regularization_vector(self):
#   def alive_vector(self):
#   def __init__(self, regularizers_to_group, threshold=DEFAULT_THRESHOLD):
#   def regularization_vector(self):
#   def alive_vector(self):
# def lazy_square(tensor):
# 
# 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/grouping_regularizers_test.py
from absl.testing import parameterized
from morph_net.framework import grouping_regularizers
from morph_net.testing import op_regularizer_stub
import numpy as np
import tensorflow.compat.v1 as tf

    with self.cached_session():
      self.assertAllEqual([x > 0.25 for x in expcted_reg_vec],
                          group_reg.alive_vector.eval())
      self.assertAllClose(expcted_reg_vec,
                          group_reg.regularization_vector.eval(), 1e-5)

  @parameterized.named_parameters(
      ('Max', grouping_regularizers.MaxGroupingRegularizer),
      ('L2', _l2_reg_with_025_threshold))
  def testOrderDoesNotMatter(self, create_reg):
    group12 = create_reg([self._reg1, self._reg2])
    group13 = create_reg([self._reg1, self._reg3])
    group23 = create_reg([self._reg2, self._reg3])

    group123 = create_reg([group12, self._reg3])
    group132 = create_reg([group13, self._reg2])
    group231 = create_reg([group23, self._reg1])

    with self.cached_session():
      self.assertAllEqual(group123.alive_vector.eval(),
                          group132.alive_vector.eval())
      self.assertAllEqual(group123.alive_vector.eval(),
                          group231.alive_vector.eval())

      self.assertAllClose(group123.regularization_vector.eval(),
                          group132.regularization_vector.eval())
      self.assertAllClose(group123.regularization_vector.eval(),
                          group231.regularization_vector.eval())

  @parameterized.named_parameters(

      ('Max', grouping_regularizers.MaxGroupingRegularizer,