internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: tensorflow/addons

Issue:
WeightNormalization fails after update
Yesterday I cut a 0.3 release on pypi test, but as a sanity check on the weightnorm changes #208 I ran a quick regression check:

https://colab.research.google.com/drive/1RQlVR9X7vj8q3W3sJC6YA3Cq45XTXrau

The new layer is failing with loss of nan. Looking at the test coverage for this layer I'm struggling how to best catch this without running a full model. The losses for our toy test cases do not return nan so perhaps we need a true regression test like mnist?

EDIT -- Fix colab link


Discussion:

Resolving patch:
diff --git a/tensorflow_addons/layers/wrappers.py b/tensorflow_addons/layers/wrappers.py
--- a/tensorflow_addons/layers/wrappers.py
+++ b/tensorflow_addons/layers/wrappers.py
@@ -88,6 +88,7 @@ def build(self, input_shape):
 
         super(WeightNormalization, self).build()
 
+    @tf.function
     def call(self, inputs):
         """Call `Layer`"""
         if not self._initialized:
@@ -143,9 +144,9 @@ def _data_dep_init(self, inputs):
             scale_init = 1. / tf.math.sqrt(v_init + 1e-10)
 
         # Assign data dependent init values
-        self.g.assign(self.g * scale_init)
+        self.g = self.g * scale_init
         if hasattr(self.layer, 'bias'):
-            self.layer.bias.assign(-m_init * scale_init)
+            self.layer.bias = -m_init * scale_init
         self.layer.activation = existing_activation
 
     def get_config(self):


Test patch:
diff --git a/tensorflow_addons/layers/wrappers_test.py b/tensorflow_addons/layers/wrappers_test.py
--- a/tensorflow_addons/layers/wrappers_test.py
+++ b/tensorflow_addons/layers/wrappers_test.py
@@ -75,7 +75,7 @@ def test_weightnorm_conv2d(self):
 
         self.assertTrue(hasattr(model.layers[0], 'g'))
 
-    def test_weightnorm_tflayers(self):
+    def test_weightnorm_applylayer(self):
         images = tf.random.uniform((2, 4, 4, 3))
         wn_wrapper = wrappers.WeightNormalization(
             tf.keras.layers.Conv2D(32, [2, 2]), input_shape=(4, 4, 3))
Repository: tensorflow/addons

Issue:
Build fails because of optimizers
Some tests for optimizers fail because of this commit https://github.com/tensorflow/tensorflow/commit/2cb745ef1e0b4082a618c81274fca39be0cb4fc6. It can be fixed by replacing `self._get_hyper('epsilon')` with `self.epsilon` when trying to access the value of epsilon. For more details, please refer to https://github.com/tensorflow/tensorflow/commit/2cb745ef1e0b4082a618c81274fca39be0cb4fc6.



Discussion:

Resolving patch:
diff --git a/tensorflow_addons/optimizers/lazy_adam.py b/tensorflow_addons/optimizers/lazy_adam.py
--- a/tensorflow_addons/optimizers/lazy_adam.py
+++ b/tensorflow_addons/optimizers/lazy_adam.py
@@ -55,7 +55,7 @@ def _resource_apply_sparse(self, grad, var, indices):
         local_step = tf.cast(self.iterations + 1, var_dtype)
         beta_1_power = tf.math.pow(beta_1_t, local_step)
         beta_2_power = tf.math.pow(beta_2_t, local_step)
-        epsilon_t = self._get_hyper('epsilon', var_dtype)
+        epsilon_t = tf.convert_to_tensor(self.epsilon, var_dtype)
         lr = (lr_t * tf.math.sqrt(1 - beta_2_power) / (1 - beta_1_power))
 
         # \\(m := beta1 * m + (1 - beta1) * g_t\\)


Test patch:
diff --git a/tensorflow_addons/optimizers/weight_decay_optimizers_test.py b/tensorflow_addons/optimizers/weight_decay_optimizers_test.py
--- a/tensorflow_addons/optimizers/weight_decay_optimizers_test.py
+++ b/tensorflow_addons/optimizers/weight_decay_optimizers_test.py
@@ -221,7 +221,7 @@ def testBasicCallableParams(self):
             learning_rate=lambda: 0.001,
             beta_1=lambda: 0.9,
             beta_2=lambda: 0.999,
-            epsilon=lambda: 1e-8,
+            epsilon=1e-8,
             weight_decay=lambda: WEIGHT_DECAY)
Repository: tensorflow/addons

Issue:
Update sparsemax to use tf.where V2
As described in #250 and temporarily patched in #251 sparsemax has one instance of tf.where that needs the broadcasting dimensions changed to match numpy and TF2 style.


Discussion:
cc @AndreasMadsen 

Resolving patch:
diff --git a/tensorflow_addons/activations/sparsemax.py b/tensorflow_addons/activations/sparsemax.py
--- a/tensorflow_addons/activations/sparsemax.py
+++ b/tensorflow_addons/activations/sparsemax.py
@@ -126,11 +126,12 @@ def _compute_2d_sparsemax(logits, name=None):
     p = tf.math.maximum(
         tf.cast(0, logits.dtype), z - tf.expand_dims(tau_z, -1))
     # If k_z = 0 or if z = nan, then the input is invalid
-    # TODO: Adjust dimension order for TF2 broadcasting
-    p_safe = tf.compat.v1.where(
-        tf.math.logical_or(
-            tf.math.equal(k_z, 0), tf.math.is_nan(z_cumsum[:, -1])),
-        tf.fill([obs, dims], tf.cast(float("nan"), logits.dtype)), p)
+    p_safe = tf.where(
+        tf.expand_dims(
+            tf.math.logical_or(
+                tf.math.equal(k_z, 0), tf.math.is_nan(z_cumsum[:, -1])),
+            axis=-1), tf.fill([obs, dims], tf.cast(float("nan"),
+                                                   logits.dtype)), p)
 
     # Reshape back to original size
     p_safe = tf.reshape(p_safe, shape_op, name=name)


Test patch:
Repository: tensorflow/addons

Issue:
tfa.text.crf_log_likelihood is not compatible with tf2.0-beta1
When implement CRF with tf2.0-beta1, got `AttributeError: module 'tensorflow' has no attribute 'get_variable'` when using tfa.text.crf_log_likelihood.
`AttributeError: in converted code:
    relative to /home/xingya:

    resume_parser/resume_parser/training/train_ner_bp.py:329 train_step  *
        log_likelihood, _ = tfa.text.crf_log_likelihood(
    .conda/envs/tf2/lib/python3.6/site-packages/tensorflow_addons/text/crf.py:191 crf_log_likelihood  *
        transition_params = tf.get_variable("transitions",
    .conda/envs/tf2/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py:329 converted_call
        f = getattr(owner, f)

    AttributeError: module 'tensorflow' has no attribute 'get_variable'` 
Accordding to the example in the [official migration_guide](https://www.tensorflow.org/beta/guide/migration_guide), It should be tf.Variable.


Discussion:
Thanks for reporting @xuxingya! Yeah `get_variable` is v1 behavior. Would you like to submit a bug fix PR?

Resolving patch:
diff --git a/tensorflow_addons/text/crf.py b/tensorflow_addons/text/crf.py
--- a/tensorflow_addons/text/crf.py
+++ b/tensorflow_addons/text/crf.py
@@ -188,8 +188,9 @@ def crf_log_likelihood(inputs,
 
     # Get the transition matrix if not provided.
     if transition_params is None:
-        transition_params = tf.get_variable("transitions",
-                                            [num_tags, num_tags])
+        initializer = tf.initializers.GlorotUniform()
+        transition_params = tf.Variable(
+            initializer([num_tags, num_tags]), "transitions")
 
     sequence_scores = crf_sequence_score(inputs, tag_indices, sequence_lengths,
                                          transition_params)


Test patch:
diff --git a/tensorflow_addons/text/crf_test.py b/tensorflow_addons/text/crf_test.py
--- a/tensorflow_addons/text/crf_test.py
+++ b/tensorflow_addons/text/crf_test.py
@@ -229,6 +229,12 @@ def testCrfLogLikelihood(self):
         tf_total_log_likelihood = self.evaluate(total_log_likelihood)
         self.assertAllClose(tf_total_log_likelihood, 0.0)
 
+        # check if `transition_params = None` raises an error
+        text.crf_log_likelihood(
+            inputs=tf.expand_dims(inputs, 0),
+            tag_indices=tf.expand_dims(tag_indices, 0),
+            sequence_lengths=tf.expand_dims(sequence_lengths, 0))
+
     def testViterbiDecode(self):
         inputs = np.array([[4, 5, -3], [3, -1, 3], [-1, 2, 1], [0, 0, 0]],
                           dtype=np.float32)
Repository: tensorflow/addons

Issue:
Package TFA 0.5.2 pinned to TF2-RC2
RC2 is released so we can do a minor release pinned to this. For now this is blocked until #539 is merged.


Discussion:
As #532 has been fixed by #539, we'll plan to release 0.5.2.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -69,9 +69,9 @@
 if project_name == TFA_RELEASE:
     # TODO: remove if-else condition when tf supports package consolidation.
     if platform.system() == 'Linux':
-        REQUIRED_PACKAGES.append('tensorflow-gpu == 2.0.0-rc1')
+        REQUIRED_PACKAGES.append('tensorflow-gpu == 2.0.0')
     else:
-        REQUIRED_PACKAGES.append('tensorflow == 2.0.0-rc1')
+        REQUIRED_PACKAGES.append('tensorflow == 2.0.0')
 elif project_name == TFA_NIGHTLY:
     # TODO: remove if-else condition when tf-nightly supports package consolidation.
     if platform.system() == 'Linux':
diff --git a/tensorflow_addons/version.py b/tensorflow_addons/version.py
--- a/tensorflow_addons/version.py
+++ b/tensorflow_addons/version.py
@@ -20,7 +20,7 @@
 # We follow Semantic Versioning (https://semver.org/)
 _MAJOR_VERSION = '0'
 _MINOR_VERSION = '5'
-_PATCH_VERSION = '1'
+_PATCH_VERSION = '2'
 
 # When building releases, we can update this value on the release branch to
 # reflect the current release candidate ('rc0', 'rc1') or, finally, the official


Test patch:
Repository: tensorflow/addons

Issue:
Build nightly from tf-nightly
Currently we build against `tf-nightly-2.0-preview`. Now that TF2 is released we should switch to `tf-nightly` once we confirm that the switch has been made.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -69,15 +69,11 @@
 if project_name == TFA_RELEASE:
     # TODO: remove if-else condition when tf supports package consolidation.
     if platform.system() == 'Linux':
-        REQUIRED_PACKAGES.append('tensorflow-gpu == 2.0.0-rc0')
+        REQUIRED_PACKAGES.append('tensorflow-gpu == 2.0.0')
     else:
-        REQUIRED_PACKAGES.append('tensorflow == 2.0.0-rc0')
+        REQUIRED_PACKAGES.append('tensorflow == 2.0.0')
 elif project_name == TFA_NIGHTLY:
-    # TODO: remove if-else condition when tf-nightly supports package consolidation.
-    if platform.system() == 'Linux':
-        REQUIRED_PACKAGES.append('tf-nightly-gpu-2.0-preview')
-    else:
-        REQUIRED_PACKAGES.append('tf-nightly-2.0-preview')
+    REQUIRED_PACKAGES.append('tf-nightly')
 
 
 class BinaryDistribution(Distribution):


Test patch:
Repository: tensorflow/addons

Issue:
Use package manager to pin TF dependency
Per https://github.com/tensorflow/community/pull/135 we should be using pip/conda to specify which Addons releases work with which TF versions. 

This is blocked until the `tensorflow` and `tensorflow-gpu` consolidation scheduled for 2.1 release


Discussion:
What is the reason to wait for the package consolidation? It seems possible to depend on `tensorflow-gpu` today.
Good question.. one reason would be that TF does not package `tensorflow-gpu` for MacOS:
https://pypi.org/project/tensorflow-gpu/2.0.0rc0/#files
Ah, it makes sense. A possible workaround could be to express the [platform dependencies](https://www.python.org/dev/peps/pep-0508/#environment-markers) in `setup.py`, e.g.:

```python
install_requires=[
    "tensorflow-gpu;platform_system!='Darwin'",
    "tensorflow;platform_system=='Darwin'",
]
```

Not sure it is something we want though...
I recall always having issues when using logic in the setup script.  Might be possible to do something with the new PEP518 approaches (e.g., https://www.python.org/dev/peps/pep-0518/).  Not 100% sure.
TensorFlow Text is using a less restrictive TensorFlow version requirement:

> `'tensorflow>=2.0.0b1, <2.1'`

https://github.com/tensorflow/text/blob/v1.0.0-beta2/oss_scripts/pip_package/setup.py#L76

Should we do something similar?
> TensorFlow Text is using a less restrictive TensorFlow version requirement:
> 
> > `'tensorflow>=2.0.0b1, <2.1'`
> 
> https://github.com/tensorflow/text/blob/v1.0.0-beta2/oss_scripts/pip_package/setup.py#L76
> 
> Should we do something similar?

In general I think we should support a greater-than versioning if we know that there were no breaks between releases (Might have to adapt our travis tests).

For this specific case I believe 2.0.0b1 will break with TFA 0.6 as Op Namespacing wasn't implemented at that point (~90% sure of that, but not positive)
Yes, I have the same concern with Guillaume. Perhaps we can always use greater-than version by default when releasing major version(say, tf >= 2.0 for addons 0.5). And we can release a minor version to pin tf version until there is a break or performance issue(say, tf>=2.0, <2.2 for addons 0.5.3).
Sounds good. Re-opening to track progress on adding greater-than

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -69,9 +69,9 @@
 if project_name == TFA_RELEASE:
     # TODO: remove if-else condition when tf supports package consolidation.
     if platform.system() == 'Linux':
-        REQUIRED_PACKAGES.append('tensorflow-gpu == 2.0.0')
+        REQUIRED_PACKAGES.append('tensorflow-gpu >= 2.0.0')
     else:
-        REQUIRED_PACKAGES.append('tensorflow == 2.0.0')
+        REQUIRED_PACKAGES.append('tensorflow >= 2.0.0')
 elif project_name == TFA_NIGHTLY:
     REQUIRED_PACKAGES.append('tf-nightly')
 


Test patch:
Repository: tensorflow/addons

Issue:
Lifted Struct Loss Error
**System information**
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Google Colab (Linux)
- TensorFlow version and how it was installed (source or binary): binary 2.0
- TensorFlow-Addons version and how it was installed (source or binary): binary 0.6.0
- Python version: 3
- Is GPU used? (yes/no): Yes

**Describe the bug**
I get an assert shape error when I try to initialize the LiftedStructLoss obj

`assert lshape.shape == 1 AssertionError` is the error I get. However, it can easily be resolved by removing the assert line. I have one more question, why does it say that the vector should not be l2 normalized? while in the case of semihardtriplet loss it says that the vector should be l2 normalized
**Code to reproduce the issue**
`import tensorflow_addons as tfa`
`tfa.losses.LiftedStructLoss()`





Discussion:

Resolving patch:
diff --git a/tensorflow_addons/losses/lifted.py b/tensorflow_addons/losses/lifted.py
--- a/tensorflow_addons/losses/lifted.py
+++ b/tensorflow_addons/losses/lifted.py
@@ -39,7 +39,6 @@ def lifted_struct_loss(labels, embeddings, margin=1.0):
     """
     # Reshape [batch_size] label tensor to a [batch_size, 1] label tensor.
     lshape = tf.shape(labels)
-    assert lshape.shape == 1
     labels = tf.reshape(labels, [lshape[0], 1])
 
     # Build pairwise squared distance matrix.


Test patch:
diff --git a/tensorflow_addons/losses/lifted_test.py b/tensorflow_addons/losses/lifted_test.py
--- a/tensorflow_addons/losses/lifted_test.py
+++ b/tensorflow_addons/losses/lifted_test.py
@@ -64,10 +64,14 @@ def testLiftedStruct(self):
         labels = np.random.randint(
             0, num_classes, size=(num_data)).astype(np.float32)
         # Reshape labels to compute adjacency matrix.
+        # pylint: disable=E1136
         labels_reshaped = np.reshape(labels, (labels.shape[0], 1))
+        # pylint: enable=E1136
 
         # Compute the loss in NP
+        # pylint: disable=E1111
         adjacency = np.equal(labels_reshaped, labels_reshaped.T)
+        # pylint: enable=E1111
         pdist_matrix = pairwise_distance_np(embedding)
         loss_np = 0.0
         num_constraints = 0.0
@@ -102,6 +106,13 @@ def testLiftedStruct(self):
         loss = cce_obj(y_true, y_pred)
         self.assertAlmostEqual(self.evaluate(loss), loss_np, 3)
 
+    def test_keras_model_compile(self):
+        model = tf.keras.models.Sequential([
+            tf.keras.layers.Input(shape=(784,)),
+            tf.keras.layers.Dense(10),
+        ])
+        model.compile(loss="Addons>lifted_struct_loss", optimizer="adam")
+
 
 if __name__ == '__main__':
     tf.test.main()
Repository: tensorflow/addons

Issue:
Allow passing in a tensor to tfa.optimizers.MovingAverage num_updates
Currently, `tfa.optimizers.MovingAverage` has an assert that requires `num_updates` to be of type int, [shown here](https://github.com/tensorflow/addons/blob/604a70de563f8797984c9c3f002aff70bef6c90b/tensorflow_addons/optimizers/moving_average.py#L81). This prevents me from passing in an integer tensor that changes with the global step, which is officially supported by `tf.train.ExponentialMovingAverage`.

Can this assert be updated to handle this use case?


Discussion:
@seanpmorgan I was looking at the code and looks like we just need to remove the check for `int`. Is that right? I will create a PR if that is right
Yes, either remove the int check or additionally check if the input is a tensor.
Thanks. Creating PR now


Resolving patch:
diff --git a/tensorflow_addons/optimizers/moving_average.py b/tensorflow_addons/optimizers/moving_average.py
--- a/tensorflow_addons/optimizers/moving_average.py
+++ b/tensorflow_addons/optimizers/moving_average.py
@@ -78,9 +78,6 @@ def __init__(self,
             raise TypeError(
                 "optimizer is not an object of tf.keras.optimizers.Optimizer")
 
-        if num_updates is not None and not isinstance(num_updates, int):
-            raise TypeError("num_updates must be None or of integer type")
-
         if not isinstance(sequential_update, bool):
             raise TypeError("sequential_update must be of bool type")
 


Test patch:
Repository: tensorflow/addons

Issue:
tfa.layers.WeightNormalization fails with Assert when called by multiple threads
### Issue description

`tfa.layers.WeightNormalization` fails with the following Tensorflow assert failure when used by multiple threads (e.g., when the same layer wrapped by `tfa.layers.WeightNormalization` is part of two parallel execution flows in a Tensorflow graph while reusing the variables):
```
(0) Invalid argument: assertion failed: [The layer has been initialized.] [Condition x == y did not hold element-wise:] [x (discriminator/discriminator_1/n_layer_discriminator/sequential_21/grouped_conv1d_3/weight_normalization_304/cond/assert_equal_1/ReadVariableOp:0) = ] [1] [y (discriminator/discriminator_1/n_layer_discriminator/sequential_21/grouped_conv1d_3/weight_normalization_304/cond/assert_equal_1/y:0) = ] [0]
[[{{node discriminator/discriminator_1/n_layer_discriminator/sequential_21/grouped_conv1d_3/weight_normalization_304/cond/assert_equal_1/Assert/AssertGuard/Assert}}]]
```

### Proposed solution

Add the following line of code to the `tfa.layers.WeightNormalization.build` function:
```
self._initialized_critical_section = tf.CriticalSection(name='initialized_mutex')
```

Replace `g = tf.cond(self._initialized, _do_nothing, _update_weights)` in the `tfa.layers.WeightNormalization.call` function with the following lines of code:
```
def _get_initialized_weights():
    return tf.cond(self._initialized, _do_nothing, _update_weights)
g = self._initialized_critical_section.execute(_get_initialized_weights)
```


Discussion:
Hi @dominikroblek, thanks for the report! Are you willing to fill a PR and add some unittests for it? Thank you again.

Resolving patch:
diff --git a/tensorflow_addons/layers/wrappers.py b/tensorflow_addons/layers/wrappers.py
--- a/tensorflow_addons/layers/wrappers.py
+++ b/tensorflow_addons/layers/wrappers.py
@@ -58,6 +58,7 @@ def __init__(self, layer, data_init=True, **kwargs):
         super(WeightNormalization, self).__init__(layer, **kwargs)
         self.data_init = data_init
         self._track_trackable(layer, name='layer')
+        self._init_critical_section = tf.CriticalSection(name='init_mutex')
         self.is_rnn = isinstance(self.layer, tf.keras.layers.RNN)
 
     def build(self, input_shape):
@@ -121,7 +122,8 @@ def _update_weights():
             with tf.control_dependencies(self._initialize_weights(inputs)):
                 return tf.identity(self.g)
 
-        g = tf.cond(self._initialized, _do_nothing, _update_weights)
+        g = self._init_critical_section.execute(lambda: tf.cond(
+            self._initialized, _do_nothing, _update_weights))
 
         with tf.name_scope('compute_weights'):
             # Replace kernel by normalized weight variable.


Test patch:
Repository: tensorflow/addons

Issue:
Nightly build break
**System information**
- TensorFlow version and how it was installed (source or binary): tf-nightly-**2.2.0.dev20200115** 
- TensorFlow-Addons version and how it was installed (source or binary): tfa-nightly-**0.8.0.dev20200115**

**Describe the bug**
Hi, it looks like [this commit](https://github.com/tensorflow/addons/commit/3aae7732998cb233234a2948010b9aaafc24e920) causes the latest nightly build to fail on import

```
----> 1 import tensorflow_addons

/usr/local/lib/python3.6/dist-packages/tensorflow_addons/__init__.py in <module>()
     30 
     31 # Cleanup symbols to avoid polluting namespace.
---> 32 del absolute_import
     33 del division
     34 del print_function

NameError: name 'absolute_import' is not defined
```
@seanpmorgan 

**Code to reproduce the issue**
[colab](https://colab.research.google.com/drive/1fxRshVv0FPJNHdOqWC4GySjPJ_TdJTJU#scrollTo=TTC3gzRLRAvY)



Discussion:
@georgesterpu Thanks great catch!

Resolving patch:
diff --git a/tensorflow_addons/__init__.py b/tensorflow_addons/__init__.py
--- a/tensorflow_addons/__init__.py
+++ b/tensorflow_addons/__init__.py
@@ -27,8 +27,3 @@
 from tensorflow_addons import text
 
 from tensorflow_addons.version import __version__
-
-# Cleanup symbols to avoid polluting namespace.
-del absolute_import
-del division
-del print_function


Test patch:
Repository: tensorflow/addons

Issue:
Incomplete and wrong typing
It seems, there are many errors in the typed code. 

For examples 
1. https://github.com/tensorflow/addons/blob/master/tensorflow_addons/activations/rrelu.py#L28 (Optional[int])
2. https://github.com/tensorflow/addons/blob/master/tensorflow_addons/losses/giou_loss.py#L101 (TensorLike)

The integration of a type checker such as `mypy` can help to keep it clean if the goal is to integrate type checking.  



Discussion:

Resolving patch:
diff --git a/tensorflow_addons/activations/rrelu.py b/tensorflow_addons/activations/rrelu.py
--- a/tensorflow_addons/activations/rrelu.py
+++ b/tensorflow_addons/activations/rrelu.py
@@ -24,8 +24,8 @@ def rrelu(
     x: types.TensorLike,
     lower: Number = 0.125,
     upper: Number = 0.3333333333333333,
-    training: Optional[str] = None,
-    seed: Optional[str] = None,
+    training: Optional[bool] = None,
+    seed: Optional[int] = None,
 ) -> tf.Tensor:
     """rrelu function.
 
diff --git a/tensorflow_addons/losses/giou_loss.py b/tensorflow_addons/losses/giou_loss.py
--- a/tensorflow_addons/losses/giou_loss.py
+++ b/tensorflow_addons/losses/giou_loss.py
@@ -17,7 +17,7 @@
 import tensorflow as tf
 
 from tensorflow_addons.utils.types import TensorLike
-from typing import List
+from typing import Optional
 from typeguard import typechecked
 
 
@@ -54,7 +54,7 @@ class GIoULoss(tf.keras.losses.Loss):
     def __init__(self,
                  mode: str = 'giou',
                  reduction: str = tf.keras.losses.Reduction.AUTO,
-                 name: str = 'giou_loss'):
+                 name: Optional[str] = 'giou_loss'):
         if mode not in ['giou', 'iou']:
             raise ValueError("Value of mode should be 'iou' or 'giou'")
         super().__init__(name=name, reduction=reduction)
@@ -98,8 +98,8 @@ def giou_loss(y_true: TensorLike,
     return 1 - giou
 
 
-def _calculate_giou(b1: List[int],
-                    b2: List[int],
+def _calculate_giou(b1: TensorLike,
+                    b2: TensorLike,
                     mode: str = 'giou') -> tf.Tensor:
     """
     Args:


Test patch: