Unverified Commit f06a6f7e authored by Emmanuel Lusenji's avatar Emmanuel Lusenji Committed by GitHub
Browse files

[WIP] Add type hints for Lxmert (TF) (#19441)



* Add type hints for Lxmert (TF)

* Update src/transformers/models/lxmert/modeling_tf_lxmert.py
Co-authored-by: default avatarEmmanuel Lusenji <elusenji@Emmanuels-MacBook-Pro.local>
Co-authored-by: default avatarMatt <Rocketknight1@users.noreply.github.com>
parent 036e8085
...@@ -18,14 +18,22 @@ ...@@ -18,14 +18,22 @@
import warnings import warnings
from dataclasses import dataclass from dataclasses import dataclass
from typing import Dict, Optional, Tuple from typing import Dict, Optional, Tuple, Union
import numpy as np
import tensorflow as tf import tensorflow as tf
from transformers.tf_utils import stable_softmax from transformers.tf_utils import stable_softmax
from ...activations_tf import get_tf_activation from ...activations_tf import get_tf_activation
from ...modeling_tf_utils import TFPreTrainedModel, get_initializer, keras_serializable, shape_list, unpack_inputs from ...modeling_tf_utils import (
TFModelInputType,
TFPreTrainedModel,
get_initializer,
keras_serializable,
shape_list,
unpack_inputs,
)
from ...utils import ( from ...utils import (
ModelOutput, ModelOutput,
add_code_sample_docstrings, add_code_sample_docstrings,
...@@ -698,7 +706,6 @@ class TFLxmertMainLayer(tf.keras.layers.Layer): ...@@ -698,7 +706,6 @@ class TFLxmertMainLayer(tf.keras.layers.Layer):
return_dict=None, return_dict=None,
training=False, training=False,
): ):
if input_ids is not None and inputs_embeds is not None: if input_ids is not None and inputs_embeds is not None:
raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time") raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
elif input_ids is not None: elif input_ids is not None:
...@@ -951,18 +958,18 @@ class TFLxmertModel(TFLxmertPreTrainedModel): ...@@ -951,18 +958,18 @@ class TFLxmertModel(TFLxmertPreTrainedModel):
) )
def call( def call(
self, self,
input_ids=None, input_ids: Optional[TFModelInputType] = None,
visual_feats=None, visual_feats: Optional[tf.Tensor] = None,
visual_pos=None, visual_pos: Optional[tf.Tensor] = None,
attention_mask=None, attention_mask: Optional[Union[np.ndarray, tf.Tensor]] = None,
visual_attention_mask=None, visual_attention_mask: Optional[Union[np.ndarray, tf.Tensor]] = None,
token_type_ids=None, token_type_ids: Optional[Union[np.ndarray, tf.Tensor]] = None,
inputs_embeds=None, inputs_embeds: Optional[Union[np.ndarray, tf.Tensor]] = None,
output_attentions=None, output_attentions: Optional[bool] = None,
output_hidden_states=None, output_hidden_states: Optional[bool] = None,
return_dict=None, return_dict: Optional[bool] = None,
training=False, training: bool = False,
): ) -> Union[Tuple, TFLxmertModelOutput]:
outputs = self.lxmert( outputs = self.lxmert(
input_ids, input_ids,
visual_feats, visual_feats,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment