# Path: morph_net/framework/conv_source_op_handler.py
# class ConvSourceOpHandler(
#     group_lasso_base_op_handler.GroupLassoBaseSourceOpHandler):
#   def _reduce_dims(self, op):
# 
# Path: morph_net/framework/generic_regularizers.py
# class NetworkRegularizer(object):  # pytype: disable=ignored-metaclass
# class OpRegularizer(object):  # pytype: disable=ignored-metaclass
#   def get_regularization_term(self, ops=None):
#   def get_cost(self, ops=None):
#   def op_regularizer_manager(self):
#   def name(self):
#   def cost_name(self):
#   def regularization_vector(self):
#   def alive_vector(self):
# def dimensions_are_compatible(op_regularizer):
# 
# Path: morph_net/framework/op_handler_decorator.py
# class OpHandlerDecorator(op_handler.OpHandler):
#   def __init__(self, handler, regularizer_decorator=None,
#                decorator_parameters=None):
#   def is_source_op(self):
#   def is_passthrough(self):
#   def assign_grouping(self, op, op_reg_manager):
#   def create_regularizer(self, op_slice):
# 
# Path: morph_net/framework/op_regularizer_manager.py
# ITERATION_LIMIT = 1000000
# class OpSlice(collections.namedtuple('OpSlice', ['op', 'slice'])):
# class Slice(collections.namedtuple('Slice', ['start_index', 'size'])):
# class OpRegularizerManager(object):
# class OpGroup(object):
#   def __str__(self):
#   def __str__(self):
#   def __init__(
#       self,
#       output_boundary: List[tf.Operation],
#       op_handler_dict=None,
#       create_grouping_regularizer=grouping_regularizers.MaxGroupingRegularizer,
#       force_group=None,
#       regularizer_blacklist=None,
#       input_boundary: List[tf.Operation] = None,
#       iteration_limit=ITERATION_LIMIT):
#   def ops(self):
#   def get_regularizer(self, op):
#   def create_op_group_for_op_slice(self, op_slice, is_source=True):
#   def group_op_slices(self, op_slices, omit_source_op_slices=None):
#   def slice_op(self, op, sizes):
#   def process_ops(self, ops):
#   def process_ops_last(self, ops):
#   def is_source_op(self, op):
#   def is_passthrough(self, op):
#   def get_op_slices(self, op):
#   def get_op_group(self, op_slice):
#   def _slice_op_slice(self, op_slice, sizes, size_index, size_count,
#                       new_op_slice_group):
#   def _slice_op_with_sizes(self, op, sizes, is_source, is_resliced):
#   def _get_source_slices(self, sizes, op_slices):
#   def _dfs_for_source_ops(self, output_boundary, input_boundary=None):
#   def _force_group_ops(self, force_group):
#   def __init__(self, op_slice=None, op_groups=None, omit_source_op_slices=None):
#   def op_slices(self):
#   def source_op_slices(self):


from morph_net.framework import conv_source_op_handler
from morph_net.framework import generic_regularizers
from morph_net.framework import op_handler_decorator
from morph_net.framework import op_regularizer_manager as orm
import numpy as np
import tensorflow.compat.v1 as tf

    Accept an OpRegularizer that is decorated by this class.

    Args:
      regularizer_object: OpRegularizer to decorate.
    """

    self._regularization_vector = regularizer_object.regularization_vector * 0.5
    self._alive_vector = regularizer_object.alive_vector

  @property
  def regularization_vector(self):
    return self._regularization_vector

  @property
  def alive_vector(self):
    return self._alive_vector


class OpHandlerDecoratorTest(tf.test.TestCase):
  """Test class for OpHandlerDecorator."""

  def testOpHandlerDecorator(self):
    image = tf.constant(0.0, shape=[1, 17, 19, 3])
    kernel = tf.ones([5, 5, 3, 3])

    output = tf.nn.conv2d(image, kernel, strides=[1, 1, 1, 1], padding='SAME')

    decorated_op_handler = op_handler_decorator.OpHandlerDecorator(
        conv_source_op_handler.ConvSourceOpHandler(1e-3, 0), DummyDecorator)

# Path: morph_net/framework/conv_source_op_handler.py
# class ConvSourceOpHandler(
#     group_lasso_base_op_handler.GroupLassoBaseSourceOpHandler):
#   def _reduce_dims(self, op):
# 
# Path: morph_net/framework/generic_regularizers.py
# class NetworkRegularizer(object):  # pytype: disable=ignored-metaclass
# class OpRegularizer(object):  # pytype: disable=ignored-metaclass
#   def get_regularization_term(self, ops=None):
#   def get_cost(self, ops=None):
#   def op_regularizer_manager(self):
#   def name(self):
#   def cost_name(self):
#   def regularization_vector(self):
#   def alive_vector(self):
# def dimensions_are_compatible(op_regularizer):
# 
# Path: morph_net/framework/op_handler_decorator.py
# class OpHandlerDecorator(op_handler.OpHandler):
#   def __init__(self, handler, regularizer_decorator=None,
#                decorator_parameters=None):
#   def is_source_op(self):
#   def is_passthrough(self):
#   def assign_grouping(self, op, op_reg_manager):
#   def create_regularizer(self, op_slice):
# 
# Path: morph_net/framework/op_regularizer_manager.py
# ITERATION_LIMIT = 1000000
# class OpSlice(collections.namedtuple('OpSlice', ['op', 'slice'])):
# class Slice(collections.namedtuple('Slice', ['start_index', 'size'])):
# class OpRegularizerManager(object):
# class OpGroup(object):
#   def __str__(self):
#   def __str__(self):
#   def __init__(
#       self,
#       output_boundary: List[tf.Operation],
#       op_handler_dict=None,
#       create_grouping_regularizer=grouping_regularizers.MaxGroupingRegularizer,
#       force_group=None,
#       regularizer_blacklist=None,
#       input_boundary: List[tf.Operation] = None,
#       iteration_limit=ITERATION_LIMIT):
#   def ops(self):
#   def get_regularizer(self, op):
#   def create_op_group_for_op_slice(self, op_slice, is_source=True):
#   def group_op_slices(self, op_slices, omit_source_op_slices=None):
#   def slice_op(self, op, sizes):
#   def process_ops(self, ops):
#   def process_ops_last(self, ops):
#   def is_source_op(self, op):
#   def is_passthrough(self, op):
#   def get_op_slices(self, op):
#   def get_op_group(self, op_slice):
#   def _slice_op_slice(self, op_slice, sizes, size_index, size_count,
#                       new_op_slice_group):
#   def _slice_op_with_sizes(self, op, sizes, is_source, is_resliced):
#   def _get_source_slices(self, sizes, op_slices):
#   def _dfs_for_source_ops(self, output_boundary, input_boundary=None):
#   def _force_group_ops(self, force_group):
#   def __init__(self, op_slice=None, op_groups=None, omit_source_op_slices=None):
#   def op_slices(self):
#   def source_op_slices(self):


# Path: morph_net/framework/op_handler_decorator_test.py
from morph_net.framework import conv_source_op_handler
from morph_net.framework import generic_regularizers
from morph_net.framework import op_handler_decorator
from morph_net.framework import op_regularizer_manager as orm
import numpy as np
import tensorflow.compat.v1 as tf


    Accept an OpRegularizer that is decorated by this class.

    Args:
      regularizer_object: OpRegularizer to decorate.
    """

    self._regularization_vector = regularizer_object.regularization_vector * 0.5
    self._alive_vector = regularizer_object.alive_vector

  @property
  def regularization_vector(self):
    return self._regularization_vector

  @property
  def alive_vector(self):
    return self._alive_vector


class OpHandlerDecoratorTest(tf.test.TestCase):
  """Test class for OpHandlerDecorator."""

  def testOpHandlerDecorator(self):
    image = tf.constant(0.0, shape=[1, 17, 19, 3])
    kernel = tf.ones([5, 5, 3, 3])

    output = tf.nn.conv2d(image, kernel, strides=[1, 1, 1, 1], padding='SAME')

    decorated_op_handler = op_handler_decorator.OpHandlerDecorator(
        conv_source_op_handler.ConvSourceOpHandler(1e-3, 0), DummyDecorator)

    op_slice = orm.OpSlice(output.op, orm.Slice(0, 3))