# Path: rigl/experimental/jax/pruning/masked.py
# def masked(module, mask):
#   """Convenience function for masking a FLAX module with MaskedModule."""
#   return MaskedModule.partial(wrapped_module=module, mask=mask)


from typing import Any, Callable, Mapping
from rigl.experimental.jax.pruning import masked
import flax
import jax.numpy as jnp
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Lint as: python3
"""Pruning mask factory.

Attributes:
  MaskFnType: A type alias for functions to create sparse masks.
  MASK_TYPES: Masks types that can be created.
"""



# A function to create a mask, takes as arguments: a flax model, JAX PRNG Key,
# sparsity level as a float in [0, 1].
MaskFnType = Callable[
    [flax.deprecated.nn.Model, Callable[[int],
                                        jnp.array], float], masked.MaskType]

MASK_TYPES: Mapping[str, MaskFnType] = {
    'random':
        masked.shuffled_mask,
    'per_neuron':
        masked.shuffled_neuron_mask,
    'per_neuron_no_input_ablation':

# Path: rigl/experimental/jax/pruning/masked.py
# def masked(module, mask):
#   """Convenience function for masking a FLAX module with MaskedModule."""
#   return MaskedModule.partial(wrapped_module=module, mask=mask)


# Path: rigl/experimental/jax/pruning/mask_factory.py
from typing import Any, Callable, Mapping
from rigl.experimental.jax.pruning import masked
import flax
import jax.numpy as jnp

#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Lint as: python3
"""Pruning mask factory.

Attributes:
  MaskFnType: A type alias for functions to create sparse masks.
  MASK_TYPES: Masks types that can be created.
"""



# A function to create a mask, takes as arguments: a flax model, JAX PRNG Key,
# sparsity level as a float in [0, 1].
MaskFnType = Callable[
    [flax.deprecated.nn.Model, Callable[[int],
                                        jnp.array], float], masked.MaskType]

MASK_TYPES: Mapping[str, MaskFnType] = {
    'random':
        masked.shuffled_mask,
    'per_neuron':
        masked.shuffled_neuron_mask,
    'per_neuron_no_input_ablation':

        masked.shuffled_neuron_no_input_ablation_mask,