# Path: flaxformer/architectures/longt5/relative_position_biases_general.py
# class RelativePositionBiasesGeneral(nn.Module):
#   def relative_position_bucket(relative_position,
#                                bidirectional=True,
#                                num_buckets=32,
#                                max_distance=128):
#   def full_att_rp_bucket(self, qlen, klen, bidirectional=True):
#   def __call__(self, rp_bucket: Array):


from absl.testing import absltest
from jax import random
from flaxformer.architectures.longt5 import relative_position_biases_general as rp_biases_general
import jax
import jax.numpy as jnp
# Copyright 2022 Google LLC.
#
# 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.

"""Tests for relative_position_biases_general.

The parameter names and outputs should be identical to the original "dense"
`RelativePositionBiases` when we use `full_att_rp_bucket()`.
"""



class RelativePositionBiasesGeneralTest(absltest.TestCase):

  def setUp(self):
    self.num_heads = 3
    self.query_len = 5
    self.key_len = 7

# Path: flaxformer/architectures/longt5/relative_position_biases_general.py
# class RelativePositionBiasesGeneral(nn.Module):
#   def relative_position_bucket(relative_position,
#                                bidirectional=True,
#                                num_buckets=32,
#                                max_distance=128):
#   def full_att_rp_bucket(self, qlen, klen, bidirectional=True):
#   def __call__(self, rp_bucket: Array):


# Path: flaxformer/architectures/longt5/relative_position_biases_general_test.py
from absl.testing import absltest
from jax import random
from flaxformer.architectures.longt5 import relative_position_biases_general as rp_biases_general
import jax
import jax.numpy as jnp

# Copyright 2022 Google LLC.
#
# 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.

"""Tests for relative_position_biases_general.

The parameter names and outputs should be identical to the original "dense"
`RelativePositionBiases` when we use `full_att_rp_bucket()`.
"""



class RelativePositionBiasesGeneralTest(absltest.TestCase):

  def setUp(self):
    self.num_heads = 3
    self.query_len = 5
    self.key_len = 7

    self.relative_attention = rp_biases_general.RelativePositionBiasesGeneral(