meerqat.models.bert module#

Copied from transformers because not accessible otherwise.

class meerqat.models.bert.BertSelfAttention(config, position_embedding_type=None)[source]#

Bases: Module

transpose_for_scores(x: Tensor) Tensor[source]#
forward(hidden_states: Tensor, attention_mask: Optional[FloatTensor] = None, head_mask: Optional[FloatTensor] = None, encoder_hidden_states: Optional[FloatTensor] = None, encoder_attention_mask: Optional[FloatTensor] = None, past_key_value: Optional[Tuple[Tuple[FloatTensor]]] = None, output_attentions: Optional[bool] = False) Tuple[Tensor][source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class meerqat.models.bert.BertSelfOutput(config)[source]#

Bases: Module

forward(hidden_states: Tensor, input_tensor: Tensor) Tensor[source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class meerqat.models.bert.BertEmbeddings(config)[source]#

Bases: Module

Construct the embeddings from word, position and token_type embeddings.

forward(input_ids: Optional[LongTensor] = None, token_type_ids: Optional[LongTensor] = None, position_ids: Optional[LongTensor] = None, inputs_embeds: Optional[FloatTensor] = None, past_key_values_length: int = 0) Tensor[source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class meerqat.models.bert.BertIntermediate(config)[source]#

Bases: Module

forward(hidden_states: Tensor) Tensor[source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class meerqat.models.bert.BertOutput(config)[source]#

Bases: Module

forward(hidden_states: Tensor, input_tensor: Tensor) Tensor[source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class meerqat.models.bert.BertPooler(config)[source]#

Bases: Module

forward(hidden_states: Tensor) Tensor[source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class meerqat.models.bert.BertAttention(config, position_embedding_type=None)[source]#

Bases: Module

prune_heads(heads)[source]#
forward(hidden_states: Tensor, attention_mask: Optional[FloatTensor] = None, head_mask: Optional[FloatTensor] = None, encoder_hidden_states: Optional[FloatTensor] = None, encoder_attention_mask: Optional[FloatTensor] = None, past_key_value: Optional[Tuple[Tuple[FloatTensor]]] = None, output_attentions: Optional[bool] = False) Tuple[Tensor][source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class meerqat.models.bert.BertLayer(config)[source]#

Bases: Module

forward(hidden_states: Tensor, attention_mask: Optional[FloatTensor] = None, head_mask: Optional[FloatTensor] = None, encoder_hidden_states: Optional[FloatTensor] = None, encoder_attention_mask: Optional[FloatTensor] = None, past_key_value: Optional[Tuple[Tuple[FloatTensor]]] = None, output_attentions: Optional[bool] = False) Tuple[Tensor][source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

feed_forward_chunk(attention_output)[source]#