# 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

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



def _l2_reg_with_025_threshold(regularizers_to_group):
  return grouping_regularizers.L2GroupingRegularizer(regularizers_to_group,
                                                     0.25)


def _l2_reg_with_05_threshold(regularizers_to_group):
  return grouping_regularizers.L2GroupingRegularizer(regularizers_to_group, 0.5)


class GroupingRegularizersTest(parameterized.TestCase, tf.test.TestCase):

  # TODO(e1): Add parametrized tests.
  def setUp(self):
    super(GroupingRegularizersTest, 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, 0.1]
    self._alive_vec2 = [False, True, False, True]
    self._reg_vec3 = [0.3, 0.2, 0.0, 0.25]
    self._alive_vec3 = [False, True, False, True]

    self._reg1 = op_regularizer_stub.OpRegularizerStub(self._reg_vec1,
                                                       self._alive_vec1)

# 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


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



def _l2_reg_with_025_threshold(regularizers_to_group):
  return grouping_regularizers.L2GroupingRegularizer(regularizers_to_group,
                                                     0.25)


def _l2_reg_with_05_threshold(regularizers_to_group):
  return grouping_regularizers.L2GroupingRegularizer(regularizers_to_group, 0.5)


class GroupingRegularizersTest(parameterized.TestCase, tf.test.TestCase):

  # TODO(e1): Add parametrized tests.
  def setUp(self):
    super(GroupingRegularizersTest, 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, 0.1]
    self._alive_vec2 = [False, True, False, True]
    self._reg_vec3 = [0.3, 0.2, 0.0, 0.25]
    self._alive_vec3 = [False, True, False, True]

    self._reg1 = op_regularizer_stub.OpRegularizerStub(self._reg_vec1,
                                                       self._alive_vec1)

    self._reg2 = op_regularizer_stub.OpRegularizerStub(self._reg_vec2,