def __init__(self,
               filters,
               contract_axes=1,
               use_bias=False,
               activation=None,
               kernel_initializer='glorot_uniform',
               bias_initializer='zeros',
               **kwargs):
    super(DenseND, self).__init__(**kwargs)
    if isinstance(filters, int):
      filters = [filters]
    self.filters = tuple(filters)
    self.contract_axes = contract_axes
    self.use_bias = use_bias
    self.activation = tf.keras.activations.get(activation)
    self.bias_initializer = bias_initializer
    self._kernel_initializer = kernel_initializer

    # Behaviours differ when shape(weights) > 2.
    # see: https://github.com/tensorflow/tensorflow/blob/r2.1/tensorflow/python/ops/init_ops_v2.py#L733 pylint: disable=line-too-long
    if self._kernel_initializer == 'glorot_uniform_nd':
      self._kernel_initializer = self._glorot_uniform