# Path: flaxformer/types.py

# 
# Path: flaxformer/types.py

# 
# Path: flaxformer/types.py

# 
# Path: flaxformer/types.py

# 
# Path: flaxformer/types.py



from typing import Union
from jax import numpy as jnp
from flaxformer.types import Array
from flaxformer.types import DType
from flaxformer.types import Initializer
from flaxformer.types import PRNGKey
from flaxformer.types import Shape
import jax
import numpy as np
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     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.

"""Initializers for Flaxformer models."""



def sinusoidal(min_scale: float = 1.0,
               max_scale: float = 10000.0,
               dtype: DType = jnp.float32) -> Initializer:
  """Creates 1D Sinusoidal Position Embedding Initializer.

  Args:
    min_scale: Minimum frequency-scale in sine grating.
    max_scale: Maximum frequency-scale in sine grating.
    dtype: The DType of the returned values.

  Returns:
    The sinusoidal initialization function.
  """


# Path: flaxformer/types.py

# 
# Path: flaxformer/types.py

# 
# Path: flaxformer/types.py

# 
# Path: flaxformer/types.py

# 
# Path: flaxformer/types.py



# Path: flaxformer/components/initializers.py
from typing import Union
from jax import numpy as jnp
from flaxformer.types import Array
from flaxformer.types import DType
from flaxformer.types import Initializer
from flaxformer.types import PRNGKey
from flaxformer.types import Shape
import jax
import numpy as np

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     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.

"""Initializers for Flaxformer models."""



def sinusoidal(min_scale: float = 1.0,
               max_scale: float = 10000.0,
               dtype: DType = jnp.float32) -> Initializer:
  """Creates 1D Sinusoidal Position Embedding Initializer.

  Args:
    min_scale: Minimum frequency-scale in sine grating.
    max_scale: Maximum frequency-scale in sine grating.
    dtype: The DType of the returned values.

  Returns:
    The sinusoidal initialization function.
  """


  def init(key: PRNGKey, shape: Shape, dtype: DType = dtype) -> Array: