id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3,500 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeEmbeddings | import torch
from torch import nn
class LukeEmbeddings(nn.Module):
"""
Same as BertEmbeddings with a tiny tweak for positional embeddings indexing.
"""
def __init__(self, config):
super().__init__()
self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=... |
class LukeEmbeddings(nn.Module):
'''
Same as BertEmbeddings with a tiny tweak for positional embeddings indexing.
'''
def __init__(self, config):
pass
def forward(self, input_ids=None, token_type_ids=None, position_ids=None, inputs_embeds=None):
pass
def create_position_ids_f... | 4 | 2 | 21 | 3 | 15 | 3 | 3 | 0.29 | 1 | 1 | 0 | 0 | 3 | 6 | 3 | 13 | 71 | 13 | 45 | 23 | 35 | 13 | 33 | 17 | 29 | 6 | 1 | 2 | 8 |
3,501 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeEncoder | from torch import nn
class LukeEncoder(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.layer = nn.ModuleList([LukeLayer(config) for _ in range(config.num_hidden_layers)])
self.gradient_checkpointing = False
def forward(self, word_hidden_sta... |
class LukeEncoder(nn.Module):
def __init__(self, config):
pass
def forward(self, word_hidden_states, entity_hidden_states, attention_mask=None, head_mask=None, output_attentions=False, output_hidden_states=False, return_dict=True):
pass | 3 | 0 | 37 | 4 | 34 | 0 | 7 | 0 | 1 | 6 | 2 | 0 | 2 | 3 | 2 | 12 | 76 | 8 | 68 | 21 | 56 | 0 | 29 | 12 | 26 | 12 | 1 | 2 | 13 |
3,502 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeEntityEmbeddings | import torch
from typing import Optional, Union
from torch import nn
from .configuration_luke import LukeConfig
class LukeEntityEmbeddings(nn.Module):
def __init__(self, config: LukeConfig):
super().__init__()
self.config = config
self.entity_embeddings = nn.Embedding(config.entity_vocab_s... |
class LukeEntityEmbeddings(nn.Module):
def __init__(self, config: LukeConfig):
pass
def forward(self, entity_ids: torch.LongTensor, position_ids: torch.LongTensor, token_type_ids: Optional[torch.LongTensor]=None):
pass | 3 | 0 | 18 | 4 | 14 | 0 | 3 | 0 | 1 | 2 | 1 | 0 | 2 | 7 | 2 | 12 | 38 | 9 | 29 | 17 | 24 | 0 | 27 | 15 | 24 | 3 | 1 | 1 | 5 |
3,503 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeForEntityClassification | import torch
from typing import Optional, Union
from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring(custom_intro='\n The LUKE model with a classification head on top (a linear layer on top of the hidden state of the first entity\n token) for entity classification tasks,... | @auto_docstring(custom_intro='\n The LUKE model with a classification head on top (a linear layer on top of the hidden state of the first entity\n token) for entity classification tasks, such as Open Entity.\n ')
class LukeForEntityClassification(LukePreTrainedModel):
def __init__(self, config):
p... | 5 | 1 | 51 | 7 | 32 | 13 | 3 | 0.39 | 1 | 5 | 2 | 0 | 2 | 4 | 2 | 3 | 106 | 14 | 66 | 28 | 45 | 26 | 23 | 11 | 20 | 5 | 2 | 2 | 6 |
3,504 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeForEntityPairClassification | import torch
from typing import Optional, Union
from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring(custom_intro='\n The LUKE model with a classification head on top (a linear layer on top of the hidden states of the two entity\n tokens) for entity pair classification t... | @auto_docstring(custom_intro='\n The LUKE model with a classification head on top (a linear layer on top of the hidden states of the two entity\n tokens) for entity pair classification tasks, such as TACRED.\n ')
class LukeForEntityPairClassification(LukePreTrainedModel):
def __init__(self, config):
... | 5 | 1 | 54 | 7 | 33 | 15 | 3 | 0.43 | 1 | 5 | 2 | 0 | 2 | 4 | 2 | 3 | 111 | 14 | 68 | 28 | 47 | 29 | 23 | 11 | 20 | 5 | 2 | 2 | 6 |
3,505 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeForEntitySpanClassification | from ...utils import ModelOutput, auto_docstring, logging
import torch
from typing import Optional, Union
from torch import nn
@auto_docstring(custom_intro='\n The LUKE model with a span classification head on top (a linear layer on top of the hidden states output) for tasks\n such as named entity recognition.\n... | @auto_docstring(custom_intro='\n The LUKE model with a span classification head on top (a linear layer on top of the hidden states output) for tasks\n such as named entity recognition.\n ')
class LukeForEntitySpanClassification(LukePreTrainedModel):
def __init__(self, config):
pass
@auto_docst... | 5 | 1 | 67 | 10 | 37 | 20 | 4 | 0.51 | 1 | 5 | 2 | 0 | 2 | 4 | 2 | 3 | 137 | 21 | 77 | 33 | 54 | 39 | 32 | 14 | 29 | 7 | 2 | 2 | 8 |
3,506 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeForMaskedLM | import torch
from typing import Optional, Union
from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring(custom_intro='\n The LUKE model with a language modeling head and entity prediction head on top for masked language modeling and\n masked entity prediction.\n ')
class... | @auto_docstring(custom_intro='\n The LUKE model with a language modeling head and entity prediction head on top for masked language modeling and\n masked entity prediction.\n ')
class LukeForMaskedLM(LukePreTrainedModel):
def __init__(self, config):
pass
def tie_weights(self):
pass
... | 8 | 1 | 23 | 3 | 18 | 3 | 2 | 0.14 | 1 | 7 | 4 | 0 | 5 | 4 | 5 | 6 | 126 | 18 | 95 | 35 | 70 | 13 | 39 | 17 | 33 | 8 | 2 | 3 | 12 |
3,507 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeForMultipleChoice | from typing import Optional, Union
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from torch import nn
import torch
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring
class LukeForMultipleChoice(LukePreTrainedModel):
def __init__(self, config):
super().__init__(co... | @auto_docstring
class LukeForMultipleChoice(LukePreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, position_ids: Optional[... | 5 | 1 | 57 | 5 | 48 | 4 | 8 | 0.08 | 1 | 5 | 2 | 0 | 2 | 3 | 2 | 3 | 121 | 11 | 102 | 30 | 77 | 8 | 32 | 13 | 29 | 14 | 2 | 1 | 16 |
3,508 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeForQuestionAnswering | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from torch import nn
import torch
from ...utils import ModelOutput, auto_docstring, logging
from typing import Optional, Union
@auto_docstring
class LukeForQuestionAnswering(LukePreTrainedModel):
def __init__(self, config):
super().__init__... | @auto_docstring
class LukeForQuestionAnswering(LukePreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, position_ids: Option... | 5 | 1 | 51 | 5 | 40 | 7 | 4 | 0.15 | 1 | 5 | 2 | 0 | 2 | 3 | 2 | 3 | 110 | 11 | 86 | 33 | 60 | 13 | 31 | 15 | 28 | 6 | 2 | 2 | 7 |
3,509 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeForSequenceClassification | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from torch import nn
import torch
from ...utils import ModelOutput, auto_docstring, logging
from typing import Optional, Union
@auto_docstring(custom_intro='\n The LUKE Model transformer with a sequence classification/regression head on top (a linear... | @auto_docstring(custom_intro='\n The LUKE Model transformer with a sequence classification/regression head on top (a linear layer on top of the\n pooled output) e.g. for GLUE tasks.\n ')
class LukeForSequenceClassification(LukePreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
... | 5 | 1 | 48 | 4 | 40 | 4 | 7 | 0.09 | 1 | 6 | 2 | 0 | 2 | 4 | 2 | 3 | 104 | 9 | 87 | 29 | 62 | 8 | 34 | 12 | 31 | 11 | 2 | 3 | 13 |
3,510 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeForTokenClassification | import torch
from ...utils import ModelOutput, auto_docstring, logging
from typing import Optional, Union
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from torch import nn
@auto_docstring(custom_intro='\n The LUKE Model with a token classification head on top (a linear layer on top of the hidde... | @auto_docstring(custom_intro='\n The LUKE Model with a token classification head on top (a linear layer on top of the hidden-states output). To\n solve Named-Entity Recognition (NER) task using LUKE, `LukeForEntitySpanClassification` is more suitable than this\n class.\n ')
class LukeForTokenClassification(... | 5 | 1 | 40 | 4 | 32 | 4 | 3 | 0.11 | 1 | 5 | 2 | 0 | 2 | 4 | 2 | 3 | 87 | 9 | 70 | 29 | 45 | 8 | 22 | 12 | 19 | 4 | 2 | 1 | 6 |
3,511 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeIntermediate | from ...activations import ACT2FN, gelu
import torch
from torch import nn
class LukeIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act, str):
self.intermedi... |
class LukeIntermediate(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 6 | 0 | 6 | 0 | 2 | 0 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 12 | 13 | 1 | 12 | 5 | 9 | 0 | 11 | 5 | 8 | 2 | 1 | 1 | 3 |
3,512 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeLMHead | import torch
from torch import nn
from ...activations import ACT2FN, gelu
class LukeLMHead(nn.Module):
"""Roberta Head for masked language modeling."""
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.layer_norm = nn.Lay... |
class LukeLMHead(nn.Module):
'''Roberta Head for masked language modeling.'''
def __init__(self, config):
pass
def forward(self, features, **kwargs):
pass
def _tie_weights(self):
pass | 4 | 1 | 8 | 1 | 6 | 1 | 1 | 0.21 | 1 | 1 | 0 | 0 | 3 | 4 | 3 | 13 | 29 | 6 | 19 | 9 | 15 | 4 | 18 | 9 | 14 | 2 | 1 | 1 | 4 |
3,513 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeLayer | from ...modeling_layers import GradientCheckpointingLayer
import torch
from ...pytorch_utils import apply_chunking_to_forward
class LukeLayer(GradientCheckpointingLayer):
def __init__(self, config):
super().__init__()
self.chunk_size_feed_forward = config.chunk_size_feed_forward
self.seq_l... |
class LukeLayer(GradientCheckpointingLayer):
def __init__(self, config):
pass
def forward(self, word_hidden_states, entity_hidden_states, attention_mask=None, head_mask=None, output_attentions=False):
pass
def feed_forward_chunk(self, attention_output):
pass | 4 | 0 | 16 | 2 | 14 | 0 | 2 | 0.02 | 1 | 4 | 3 | 0 | 3 | 5 | 3 | 13 | 50 | 7 | 43 | 25 | 32 | 1 | 26 | 18 | 22 | 3 | 1 | 1 | 5 |
3,514 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeMaskedLMOutput | from ...utils import ModelOutput, auto_docstring, logging
from dataclasses import dataclass
import torch
from typing import Optional, Union
@dataclass
@auto_docstring(custom_intro="\n Base class for model's outputs, with potential hidden states and attentions.\n ")
class LukeMaskedLMOutput(ModelOutput):
"""
... | @dataclass
@auto_docstring(custom_intro="\n Base class for model's outputs, with potential hidden states and attentions.\n ")
class LukeMaskedLMOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
The sum of masked language modeling (... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 40 | 4 | 9 | 9 | 8 | 27 | 9 | 9 | 8 | 0 | 1 | 0 | 0 |
3,515 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeModel | from ...utils import ModelOutput, auto_docstring, logging
from .configuration_luke import LukeConfig
import torch
from typing import Optional, Union
@auto_docstring(custom_intro='\n The bare LUKE model transformer outputting raw hidden-states for both word tokens and entities without any\n ')
class LukeModel(Luk... | @auto_docstring(custom_intro='\n The bare LUKE model transformer outputting raw hidden-states for both word tokens and entities without any\n ')
class LukeModel(LukePreTrainedModel):
def __init__(self, config: LukeConfig, add_pooling_layer: bool=True):
'''
add_pooling_layer (bool, *optional*,... | 11 | 3 | 24 | 3 | 14 | 7 | 3 | 0.49 | 1 | 10 | 6 | 0 | 8 | 5 | 8 | 9 | 198 | 34 | 111 | 44 | 83 | 54 | 64 | 26 | 55 | 16 | 2 | 2 | 27 |
3,516 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeMultipleChoiceModelOutput | from dataclasses import dataclass
import torch
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
@dataclass
@auto_docstring(custom_intro='\n Outputs of multiple choice models.\n ')
class LukeMultipleChoiceModelOutput(ModelOutput):
"""
loss (`torch.FloatTensor` o... | @dataclass
@auto_docstring(custom_intro='\n Outputs of multiple choice models.\n ')
class LukeMultipleChoiceModelOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape *(1,)*, *optional*, returned when `labels` is provided):
Classification loss.
logits (`torch.FloatTensor` of shape `(batc... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.67 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 33 | 5 | 6 | 6 | 5 | 22 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
3,517 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeOutput | import torch
from torch import nn
class LukeOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.intermediate_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.dropout = nn.Dropout(... |
class LukeOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 3 | 2 | 12 | 12 | 1 | 11 | 6 | 8 | 0 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
3,518 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukePooler | import torch
from torch import nn
class LukePooler(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.activation = nn.Tanh()
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
first_token_... |
class LukePooler(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 6 | 0 | 5 | 1 | 1 | 0.2 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 12 | 13 | 1 | 10 | 7 | 7 | 2 | 10 | 7 | 7 | 1 | 1 | 0 | 2 |
3,519 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukePreTrainedModel | from ...modeling_utils import PreTrainedModel
from .configuration_luke import LukeConfig
from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring
class LukePreTrainedModel(PreTrainedModel):
config: LukeConfig
base_model_prefix = 'luke'
supports_gradient_checkpointing =... | @auto_docstring
class LukePreTrainedModel(PreTrainedModel):
def _init_weights(self, module: nn.Module):
'''Initialize the weights'''
pass | 3 | 1 | 16 | 0 | 15 | 2 | 7 | 0.3 | 1 | 0 | 0 | 9 | 1 | 0 | 1 | 1 | 27 | 2 | 20 | 6 | 18 | 6 | 17 | 6 | 15 | 7 | 1 | 2 | 7 |
3,520 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeQuestionAnsweringModelOutput | from dataclasses import dataclass
import torch
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
@dataclass
@auto_docstring(custom_intro='\n Outputs of question answering models.\n ')
class LukeQuestionAnsweringModelOutput(ModelOutput):
"""
loss (`torch.FloatTen... | @dataclass
@auto_docstring(custom_intro='\n Outputs of question answering models.\n ')
class LukeQuestionAnsweringModelOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Total span extraction loss is the sum of a Cross-Entropy for t... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.29 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 34 | 4 | 7 | 7 | 6 | 23 | 7 | 7 | 6 | 0 | 1 | 0 | 0 |
3,521 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeSelfAttention | import torch
from torch import nn
import math
class LukeSelfAttention(nn.Module):
def __init__(self, config):
super().__init__()
if config.hidden_size % config.num_attention_heads != 0 and (not hasattr(config, 'embedding_size')):
raise ValueError(f'The hidden size {config.hidden_size} ... |
class LukeSelfAttention(nn.Module):
def __init__(self, config):
pass
def transpose_for_scores(self, x):
pass
def forward(self, word_hidden_states, entity_hidden_states, attention_mask=None, head_mask=None, output_attentions=False):
pass | 4 | 0 | 36 | 7 | 26 | 3 | 4 | 0.13 | 1 | 3 | 0 | 0 | 3 | 11 | 3 | 13 | 111 | 22 | 79 | 49 | 68 | 10 | 65 | 42 | 61 | 7 | 1 | 1 | 11 |
3,522 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeSelfOutput | import torch
from torch import nn
class LukeSelfOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.dropout = nn.Dropout(co... |
class LukeSelfOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 3 | 2 | 12 | 12 | 1 | 11 | 6 | 8 | 0 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
3,523 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeSequenceClassifierOutput | from ...utils import ModelOutput, auto_docstring, logging
from dataclasses import dataclass
import torch
from typing import Optional, Union
@dataclass
@auto_docstring(custom_intro='\n Outputs of sentence classification models.\n ')
class LukeSequenceClassifierOutput(ModelOutput):
"""
loss (`torch.FloatTe... | @dataclass
@auto_docstring(custom_intro='\n Outputs of sentence classification models.\n ')
class LukeSequenceClassifierOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Classification (or regression if config.num_labels==1) loss.
... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 31 | 4 | 6 | 6 | 5 | 21 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
3,524 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/modeling_luke.py | transformers.models.luke.modeling_luke.LukeTokenClassifierOutput | from ...utils import ModelOutput, auto_docstring, logging
from dataclasses import dataclass
import torch
from typing import Optional, Union
@dataclass
@auto_docstring(custom_intro='\n Base class for outputs of token classification models.\n ')
class LukeTokenClassifierOutput(ModelOutput):
"""
loss (`torc... | @dataclass
@auto_docstring(custom_intro='\n Base class for outputs of token classification models.\n ')
class LukeTokenClassifierOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Classification loss.
logits (`torch.FloatTensor`... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 31 | 4 | 6 | 6 | 5 | 21 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
3,525 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/luke/tokenization_luke.py | transformers.models.luke.tokenization_luke.LukeTokenizer | import itertools
import numpy as np
from ...utils import add_end_docstrings, is_torch_tensor, logging
import os
import json
from collections.abc import Mapping
from ...tokenization_utils_base import ENCODE_KWARGS_DOCSTRING, AddedToken, BatchEncoding, EncodedInput, PaddingStrategy, TensorType, TextInput, TextInputPair, ... |
class LukeTokenizer(PreTrainedTokenizer):
'''
Constructs a LUKE tokenizer, derived from the GPT-2 tokenizer, using byte-level Byte-Pair-Encoding.
This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will
be encoded differently whether it is at th... | 29 | 13 | 61 | 6 | 46 | 9 | 8 | 0.29 | 1 | 22 | 2 | 0 | 22 | 17 | 22 | 111 | 1,555 | 172 | 1,084 | 357 | 865 | 310 | 497 | 148 | 472 | 30 | 3 | 4 | 182 |
3,526 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/configuration_lxmert.py | transformers.models.lxmert.configuration_lxmert.LxmertConfig | from ...configuration_utils import PretrainedConfig
class LxmertConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`LxmertModel`] or a [`TFLxmertModel`]. It is used
to instantiate a LXMERT model according to the specified arguments, defining the model architectur... |
class LxmertConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`LxmertModel`] or a [`TFLxmertModel`]. It is used
to instantiate a LXMERT model according to the specified arguments, defining the model architecture. Instantiating
a configuration with the defaul... | 2 | 1 | 60 | 0 | 60 | 0 | 1 | 1.19 | 1 | 1 | 0 | 0 | 1 | 28 | 1 | 1 | 143 | 5 | 63 | 62 | 31 | 75 | 33 | 32 | 31 | 1 | 1 | 0 | 1 |
3,527 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.GeLU | from torch import nn
from ...activations import ACT2FN, gelu
class GeLU(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return gelu(x) |
class GeLU(nn.Module):
def __init__(self):
pass
def forward(self, x):
pass | 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 0 | 2 | 12 | 6 | 1 | 5 | 3 | 2 | 0 | 5 | 3 | 2 | 1 | 1 | 0 | 2 |
3,528 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertAttention | import math
import torch
from torch import nn
class LxmertAttention(nn.Module):
def __init__(self, config, ctx_dim=None):
super().__init__()
if config.hidden_size % config.num_attention_heads != 0:
raise ValueError(f'The hidden size ({config.hidden_size}) is not a multiple of the numbe... |
class LxmertAttention(nn.Module):
def __init__(self, config, ctx_dim=None):
pass
def forward(self, hidden_states, context, attention_mask=None, output_attentions=False):
pass | 3 | 0 | 19 | 3 | 14 | 2 | 2 | 0.14 | 1 | 3 | 0 | 0 | 3 | 7 | 3 | 13 | 59 | 10 | 43 | 23 | 39 | 6 | 37 | 23 | 33 | 3 | 1 | 1 | 7 |
3,529 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertAttentionOutput | from torch import nn
class LxmertAttentionOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=1e-12)
self.dropout = nn.Dropout(config.hidden_dropout_pr... |
class LxmertAttentionOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states, input_tensor):
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 3 | 2 | 12 | 12 | 1 | 11 | 6 | 8 | 0 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
3,530 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertCrossAttentionLayer | from torch import nn
class LxmertCrossAttentionLayer(nn.Module):
def __init__(self, config):
super().__init__()
self.att = LxmertAttention(config)
self.output = LxmertAttentionOutput(config)
def forward(self, input_tensor, ctx_tensor, ctx_att_mask=None, output_attentions=False):
... |
class LxmertCrossAttentionLayer(nn.Module):
def __init__(self, config):
pass
def forward(self, input_tensor, ctx_tensor, ctx_att_mask=None, output_attentions=False):
pass | 3 | 0 | 6 | 0 | 6 | 0 | 2 | 0 | 1 | 3 | 2 | 0 | 2 | 2 | 2 | 12 | 13 | 1 | 12 | 9 | 9 | 0 | 12 | 9 | 9 | 3 | 1 | 1 | 4 |
3,531 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertEmbeddings | import torch
from torch import nn
class LxmertEmbeddings(nn.Module):
"""Construct the embeddings from word, position and token_type embeddings."""
def __init__(self, config):
super().__init__()
self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=0)
se... |
class LxmertEmbeddings(nn.Module):
'''Construct the embeddings from word, position and token_type embeddings.'''
def __init__(self, config):
pass
def forward(self, input_ids, token_type_ids=None, inputs_embeds=None):
pass | 3 | 1 | 17 | 3 | 14 | 1 | 3 | 0.11 | 1 | 1 | 0 | 0 | 2 | 5 | 2 | 12 | 38 | 7 | 28 | 15 | 25 | 3 | 27 | 15 | 24 | 4 | 1 | 1 | 5 |
3,532 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertEncoder | from torch import nn
class LxmertEncoder(nn.Module):
def __init__(self, config):
super().__init__()
self.visn_fc = LxmertVisualFeatureEncoder(config)
self.config = config
self.num_l_layers = config.l_layers
self.num_x_layers = config.x_layers
self.num_r_layers = con... |
class LxmertEncoder(nn.Module):
def __init__(self, config):
pass
def forward(self, lang_feats, lang_attention_mask, visual_feats, visual_pos, visual_attention_mask=None, output_attentions=None):
pass | 3 | 0 | 39 | 4 | 32 | 4 | 7 | 0.11 | 1 | 5 | 3 | 0 | 2 | 8 | 2 | 12 | 79 | 8 | 64 | 30 | 53 | 7 | 40 | 22 | 37 | 13 | 1 | 2 | 14 |
3,533 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertForPreTraining | from ...utils import ModelOutput, auto_docstring, logging
from torch import nn
import torch
from torch.nn import CrossEntropyLoss, SmoothL1Loss
import warnings
from typing import Optional, Union
@auto_docstring
class LxmertForPreTraining(LxmertPreTrainedModel):
_tied_weights_keys = ['cls.predictions.decoder.weight... | @auto_docstring
class LxmertForPreTraining(LxmertPreTrainedModel):
def __init__(self, config):
pass
def _tie_weights(self):
pass
def resize_token_embeddings(self, new_num_tokens: int, pad_to_multiple_of: Optional[int]=None, mean_resizing: bool=True) -> nn.Embedding:
pass
def ... | 13 | 3 | 30 | 3 | 22 | 5 | 4 | 0.24 | 1 | 11 | 5 | 0 | 9 | 13 | 9 | 10 | 280 | 35 | 199 | 77 | 168 | 47 | 116 | 57 | 106 | 14 | 2 | 3 | 34 |
3,534 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertForPreTrainingOutput | from ...utils import ModelOutput, auto_docstring, logging
import torch
from dataclasses import dataclass
from typing import Optional, Union
@dataclass
@auto_docstring(custom_intro='\n Output type of [`LxmertForPreTraining`].\n ')
class LxmertForPreTrainingOutput(ModelOutput):
"""
loss (*optional*, return... | @dataclass
@auto_docstring(custom_intro='\n Output type of [`LxmertForPreTraining`].\n ')
class LxmertForPreTrainingOutput(ModelOutput):
'''
loss (*optional*, returned when `labels` is provided, `torch.FloatTensor` of shape `(1,)`):
Total loss as the sum of the masked language modeling loss and th... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 45 | 3 | 10 | 10 | 9 | 32 | 10 | 10 | 9 | 0 | 1 | 0 | 0 |
3,535 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertForQuestionAnswering | from torch import nn
import torch
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
from torch.nn import CrossEntropyLoss, SmoothL1Loss
@auto_docstring(custom_intro='\n Lxmert Model with a visual-answering head on top for downstream QA tasks\n ')
class LxmertForQuestion... | @auto_docstring(custom_intro='\n Lxmert Model with a visual-answering head on top for downstream QA tasks\n ')
class LxmertForQuestionAnswering(LxmertPreTrainedModel):
def __init__(self, config):
pass
def resize_num_qa_labels(self, num_labels):
'''
Build a resized question answer... | 10 | 3 | 20 | 3 | 13 | 4 | 2 | 0.31 | 1 | 6 | 3 | 0 | 7 | 6 | 7 | 8 | 150 | 26 | 95 | 40 | 68 | 29 | 56 | 26 | 48 | 5 | 2 | 1 | 17 |
3,536 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertForQuestionAnsweringOutput | from ...utils import ModelOutput, auto_docstring, logging
from dataclasses import dataclass
from typing import Optional, Union
import torch
@dataclass
@auto_docstring(custom_intro='\n Output type of [`LxmertForQuestionAnswering`].\n ')
class LxmertForQuestionAnsweringOutput(ModelOutput):
"""
loss (*optio... | @dataclass
@auto_docstring(custom_intro='\n Output type of [`LxmertForQuestionAnswering`].\n ')
class LxmertForQuestionAnsweringOutput(ModelOutput):
'''
loss (*optional*, returned when `labels` is provided, `torch.FloatTensor` of shape `(1,)`):
Total loss as the sum of the masked language modeling... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.38 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 37 | 2 | 8 | 8 | 7 | 27 | 8 | 8 | 7 | 0 | 1 | 0 | 0 |
3,537 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertIntermediate | from torch import nn
from ...activations import ACT2FN, gelu
class LxmertIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
self.intermediate_act_fn = ACT2FN[config.hidden_act]
def forward(self, ... |
class LxmertIntermediate(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 10 | 1 | 9 | 5 | 6 | 0 | 9 | 5 | 6 | 1 | 1 | 0 | 2 |
3,538 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertLMPredictionHead | import torch
from torch import nn
class LxmertLMPredictionHead(nn.Module):
def __init__(self, config, lxmert_model_embedding_weights):
super().__init__()
self.transform = LxmertPredictionHeadTransform(config)
self.decoder = nn.Linear(lxmert_model_embedding_weights.size(1), lxmert_model_emb... |
class LxmertLMPredictionHead(nn.Module):
def __init__(self, config, lxmert_model_embedding_weights):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 9 | 1 | 7 | 1 | 1 | 0.13 | 1 | 2 | 1 | 0 | 2 | 3 | 2 | 12 | 19 | 2 | 15 | 6 | 12 | 2 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
3,539 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertLayer | from torch import nn
class LxmertLayer(nn.Module):
def __init__(self, config):
super().__init__()
self.attention = LxmertSelfAttentionLayer(config)
self.intermediate = LxmertIntermediate(config)
self.output = LxmertOutput(config)
def forward(self, hidden_states, attention_mask... |
class LxmertLayer(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states, attention_mask=None, output_attentions=False):
pass | 3 | 0 | 6 | 0 | 6 | 1 | 1 | 0.08 | 1 | 4 | 3 | 0 | 2 | 3 | 2 | 12 | 14 | 1 | 13 | 10 | 10 | 1 | 13 | 10 | 10 | 1 | 1 | 0 | 2 |
3,540 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertModel | from typing import Optional, Union
import torch
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring
class LxmertModel(LxmertPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.embeddings = LxmertEmbeddings(config)
self.encoder = LxmertEncoder(c... | @auto_docstring
class LxmertModel(LxmertPreTrainedModel):
def __init__(self, config):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, new_embeddings):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, visual_feats: ... | 7 | 1 | 31 | 4 | 23 | 4 | 6 | 0.14 | 1 | 7 | 4 | 0 | 4 | 3 | 4 | 5 | 132 | 18 | 100 | 38 | 77 | 14 | 56 | 25 | 51 | 21 | 2 | 1 | 24 |
3,541 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertModelOutput | from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
import torch
from dataclasses import dataclass
@dataclass
@auto_docstring(custom_intro='\n Lxmert\'s outputs that contain the last hidden states, pooled outputs, and attention probabilities for the language,\n visual, an... | @dataclass
@auto_docstring(custom_intro='\n Lxmert\'s outputs that contain the last hidden states, pooled outputs, and attention probabilities for the language,\n visual, and, cross-modality encoders. (note: the visual encoder in Lxmert is referred to as the "relation-ship"\n encoder")\n ')
class LxmertMode... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.44 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 43 | 3 | 9 | 9 | 8 | 31 | 9 | 9 | 8 | 0 | 1 | 0 | 0 |
3,542 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertOutput | from torch import nn
class LxmertOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.intermediate_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=1e-12)
self.dropout = nn.Dropout(config.hidden_dropout_prob)... |
class LxmertOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states, input_tensor):
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 3 | 2 | 12 | 12 | 1 | 11 | 6 | 8 | 0 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
3,543 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertPooler | from torch import nn
class LxmertPooler(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.activation = nn.Tanh()
def forward(self, hidden_states):
first_token_tensor = hidden_states[:, 0]
pool... |
class LxmertPooler(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 6 | 0 | 5 | 1 | 1 | 0.2 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 13 | 1 | 10 | 7 | 7 | 2 | 10 | 7 | 7 | 1 | 1 | 0 | 2 |
3,544 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertPreTrainedModel | from torch import nn
from .configuration_lxmert import LxmertConfig
from ...utils import ModelOutput, auto_docstring, logging
from ...modeling_utils import PreTrainedModel
@auto_docstring
class LxmertPreTrainedModel(PreTrainedModel):
config: LxmertConfig
base_model_prefix = 'lxmert'
_supports_param_buffer_... | @auto_docstring
class LxmertPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 15 | 0 | 12 | 3 | 6 | 0.41 | 1 | 0 | 0 | 3 | 1 | 0 | 1 | 1 | 26 | 2 | 17 | 6 | 15 | 7 | 15 | 6 | 13 | 6 | 1 | 2 | 6 |
3,545 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertPreTrainingHeads | from torch import nn
class LxmertPreTrainingHeads(nn.Module):
def __init__(self, config, lxmert_model_embedding_weights):
super().__init__()
self.predictions = LxmertLMPredictionHead(config, lxmert_model_embedding_weights)
self.seq_relationship = nn.Linear(config.hidden_size, 2)
def f... |
class LxmertPreTrainingHeads(nn.Module):
def __init__(self, config, lxmert_model_embedding_weights):
pass
def forward(self, sequence_output, pooled_output):
pass | 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 2 | 2 | 2 | 12 | 10 | 1 | 9 | 7 | 6 | 0 | 9 | 7 | 6 | 1 | 1 | 0 | 2 |
3,546 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertPredictionHeadTransform | from ...activations import ACT2FN, gelu
from torch import nn
class LxmertPredictionHeadTransform(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.transform_act_fn = ACT2FN[config.hidden_act]
self.LayerNor... |
class LxmertPredictionHeadTransform(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 3 | 2 | 12 | 12 | 1 | 11 | 6 | 8 | 0 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
3,547 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertSelfAttentionLayer | from torch import nn
class LxmertSelfAttentionLayer(nn.Module):
def __init__(self, config):
super().__init__()
self.self = LxmertAttention(config)
self.output = LxmertAttentionOutput(config)
def forward(self, input_tensor, attention_mask, output_attentions=False):
output = sel... |
class LxmertSelfAttentionLayer(nn.Module):
def __init__(self, config):
pass
def forward(self, input_tensor, attention_mask, output_attentions=False):
pass | 3 | 0 | 9 | 0 | 8 | 1 | 2 | 0.06 | 1 | 3 | 2 | 0 | 2 | 2 | 2 | 12 | 19 | 1 | 17 | 9 | 14 | 1 | 12 | 9 | 9 | 3 | 1 | 1 | 4 |
3,548 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertVisualAnswerHead | from torch import nn
class LxmertVisualAnswerHead(nn.Module):
def __init__(self, config, num_labels):
super().__init__()
hid_dim = config.hidden_size
self.logit_fc = nn.Sequential(nn.Linear(hid_dim, hid_dim * 2), GeLU(), nn.LayerNorm(hid_dim * 2, eps=1e-12), nn.Linear(hid_dim * 2, num_labe... |
class LxmertVisualAnswerHead(nn.Module):
def __init__(self, config, num_labels):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 2 | 1 | 2 | 12 | 13 | 1 | 12 | 5 | 9 | 0 | 7 | 5 | 4 | 1 | 1 | 0 | 2 |
3,549 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertVisualFeatureEncoder | from torch import nn
class LxmertVisualFeatureEncoder(nn.Module):
def __init__(self, config):
super().__init__()
feat_dim = config.visual_feat_dim
pos_dim = config.visual_pos_dim
self.visn_fc = nn.Linear(feat_dim, config.hidden_size)
self.visn_layer_norm = nn.LayerNorm(conf... |
class LxmertVisualFeatureEncoder(nn.Module):
def __init__(self, config):
pass
def forward(self, visual_feats, visual_pos):
pass | 3 | 0 | 12 | 2 | 9 | 1 | 1 | 0.11 | 1 | 1 | 0 | 0 | 2 | 5 | 2 | 12 | 25 | 5 | 18 | 13 | 15 | 2 | 18 | 13 | 15 | 1 | 1 | 0 | 2 |
3,550 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertVisualObjHead | from torch import nn
class LxmertVisualObjHead(nn.Module):
def __init__(self, config):
super().__init__()
self.transform = LxmertPredictionHeadTransform(config)
visual_losses = {}
if config.visual_obj_loss:
visual_losses['obj'] = {'shape': (-1,), 'num': config.num_objec... |
class LxmertVisualObjHead(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 14 | 1 | 12 | 2 | 3 | 0.13 | 1 | 2 | 1 | 0 | 2 | 3 | 2 | 12 | 29 | 2 | 24 | 9 | 21 | 3 | 19 | 9 | 16 | 4 | 1 | 1 | 6 |
3,551 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/modeling_lxmert.py | transformers.models.lxmert.modeling_lxmert.LxmertXLayer | from torch import nn
class LxmertXLayer(nn.Module):
def __init__(self, config):
super().__init__()
self.visual_attention = LxmertCrossAttentionLayer(config)
self.lang_self_att = LxmertSelfAttentionLayer(config)
self.visn_self_att = LxmertSelfAttentionLayer(config)
self.lang... |
class LxmertXLayer(nn.Module):
def __init__(self, config):
pass
def cross_att(self, lang_input, lang_attention_mask, visual_input, visual_attention_mask, output_x_attentions=False):
pass
def self_att(self, lang_input, lang_attention_mask, visual_input, visual_attention_mask):
pas... | 6 | 0 | 17 | 1 | 14 | 1 | 1 | 0.1 | 1 | 5 | 4 | 0 | 5 | 7 | 5 | 15 | 89 | 9 | 73 | 38 | 53 | 7 | 30 | 24 | 24 | 2 | 1 | 0 | 6 |
3,552 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/tokenization_lxmert.py | transformers.models.lxmert.tokenization_lxmert.LxmertTokenizer | import os
from typing import Optional
from ...tokenization_utils import PreTrainedTokenizer, _is_control, _is_punctuation, _is_whitespace
import collections
class LxmertTokenizer(PreTrainedTokenizer):
"""
Construct a Lxmert tokenizer. Based on WordPiece.
This tokenizer inherits from [`PreTrainedTokenizer`... |
class LxmertTokenizer(PreTrainedTokenizer):
'''
Construct a Lxmert tokenizer. Based on WordPiece.
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.
Args:
vocab_fil... | 14 | 6 | 15 | 1 | 10 | 4 | 2 | 0.72 | 1 | 9 | 2 | 0 | 12 | 5 | 12 | 101 | 236 | 29 | 121 | 53 | 85 | 87 | 65 | 29 | 52 | 6 | 3 | 3 | 27 |
3,553 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lxmert/tokenization_lxmert_fast.py | transformers.models.lxmert.tokenization_lxmert_fast.LxmertTokenizerFast | from .tokenization_lxmert import LxmertTokenizer
import json
from typing import Optional
from tokenizers import normalizers
from ...tokenization_utils_fast import PreTrainedTokenizerFast
class LxmertTokenizerFast(PreTrainedTokenizerFast):
"""
Construct a "fast" Lxmert tokenizer (backed by HuggingFace's *tokeni... |
class LxmertTokenizerFast(PreTrainedTokenizerFast):
'''
Construct a "fast" Lxmert tokenizer (backed by HuggingFace's *tokenizers* library). Based on WordPiece.
This tokenizer inherits from [`PreTrainedTokenizerFast`] which contains most of the main methods. Users should
refer to this superclass for mor... | 4 | 2 | 24 | 3 | 14 | 7 | 2 | 1.12 | 1 | 4 | 0 | 0 | 4 | 1 | 4 | 92 | 141 | 18 | 58 | 29 | 38 | 65 | 27 | 14 | 22 | 2 | 3 | 1 | 7 |
3,554 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/configuration_m2m_100.py | transformers.models.m2m_100.configuration_m2m_100.M2M100Config | from ...configuration_utils import PretrainedConfig
class M2M100Config(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`M2M100Model`]. It is used to instantiate an
M2M100 model according to the specified arguments, defining the model architecture. Instantiating a con... |
class M2M100Config(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`M2M100Model`]. It is used to instantiate an
M2M100 model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a simila... | 2 | 1 | 55 | 1 | 54 | 1 | 1 | 1.03 | 1 | 1 | 0 | 0 | 1 | 19 | 1 | 1 | 128 | 11 | 58 | 50 | 30 | 60 | 25 | 24 | 23 | 1 | 1 | 0 | 1 |
3,555 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/configuration_m2m_100.py | transformers.models.m2m_100.configuration_m2m_100.M2M100OnnxConfig | from typing import Any
from ... import PreTrainedTokenizer
from ...onnx.utils import compute_effective_axis_dimension
from ...onnx import OnnxConfig, OnnxSeq2SeqConfigWithPast
from ...utils import is_torch_available, logging
from collections import OrderedDict
from collections.abc import Mapping
class M2M100OnnxConfig... |
class M2M100OnnxConfig(OnnxSeq2SeqConfigWithPast):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
pass
def _generate_dummy_inputs_for_sequence_classification_and_question_answering(self, tokenizer: PreTrainedTokenizer, batch_size: int=-1, seq_length: int=-1, is_pair: bool=False) -... | 5 | 0 | 37 | 3 | 31 | 3 | 4 | 0.14 | 1 | 8 | 0 | 0 | 3 | 0 | 3 | 3 | 121 | 12 | 96 | 40 | 76 | 13 | 47 | 25 | 42 | 8 | 1 | 2 | 12 |
3,556 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/modeling_m2m_100.py | transformers.models.m2m_100.modeling_m2m_100.M2M100Attention | from .configuration_m2m_100 import M2M100Config
from ...utils.deprecation import deprecate_kwarg
from typing import Callable, Optional, Union
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...modeling_flash_attention_utils import FlashAttentionKwargs
from torch import nn
from ...modeling_utils... |
class M2M100Attention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, embed_dim: int, num_heads: int, dropout: float=0.0, is_decoder: bool=False, bias: bool=True, is_causal: bool=False, config: Optional[M2M100Config]=None, layer_idx: Optional[int]=None):
... | 4 | 2 | 50 | 7 | 35 | 8 | 5 | 0.24 | 1 | 7 | 1 | 2 | 3 | 12 | 3 | 13 | 156 | 23 | 107 | 44 | 86 | 26 | 68 | 27 | 64 | 12 | 1 | 2 | 15 |
3,557 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/modeling_m2m_100.py | transformers.models.m2m_100.modeling_m2m_100.M2M100Decoder | from torch import nn
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...integrations.deepspeed import is_deepspeed_zero3_enabled
from ...integrations.fsdp import is_fsdp_managed_mod... |
class M2M100Decoder(M2M100PreTrainedModel):
'''
Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`M2M100DecoderLayer`]
Args:
config: M2M100Config
embed_tokens (nn.Embedding): output embedding
'''
def __init__(self, config: M2M100Config, embed_token... | 3 | 2 | 137 | 20 | 82 | 36 | 23 | 0.47 | 1 | 13 | 5 | 0 | 2 | 11 | 2 | 3 | 283 | 42 | 164 | 46 | 147 | 77 | 83 | 32 | 80 | 43 | 2 | 3 | 46 |
3,558 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/modeling_m2m_100.py | transformers.models.m2m_100.modeling_m2m_100.M2M100DecoderLayer | from ...utils.deprecation import deprecate_kwarg
from .configuration_m2m_100 import M2M100Config
from ...modeling_layers import GradientCheckpointingLayer
from torch import nn
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Callable, Optional, Union
from ...activation... |
class M2M100DecoderLayer(GradientCheckpointingLayer):
def __init__(self, config: M2M100Config, layer_idx: Optional[int]=None):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=N... | 4 | 1 | 58 | 6 | 40 | 13 | 4 | 0.31 | 1 | 4 | 1 | 0 | 2 | 11 | 2 | 12 | 118 | 12 | 81 | 32 | 67 | 25 | 44 | 21 | 41 | 6 | 1 | 1 | 7 |
3,559 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/modeling_m2m_100.py | transformers.models.m2m_100.modeling_m2m_100.M2M100Encoder | from .configuration_m2m_100 import M2M100Config
from typing import Callable, Optional, Union
import torch
import math
from torch import nn
from ...integrations.deepspeed import is_deepspeed_zero3_enabled
from ...integrations.fsdp import is_fsdp_managed_module
from ...modeling_outputs import BaseModelOutput, BaseModelOu... |
class M2M100Encoder(M2M100PreTrainedModel):
'''
Transformer encoder consisting of *config.encoder_layers* self attention layers. Each layer is a
[`M2M100EncoderLayer`].
Args:
config: M2M100Config
embed_tokens (nn.Embedding): output embedding
'''
def __init__(self, config: M2M10... | 3 | 2 | 87 | 15 | 53 | 20 | 15 | 0.44 | 1 | 12 | 5 | 0 | 2 | 11 | 2 | 3 | 185 | 32 | 106 | 35 | 94 | 47 | 67 | 26 | 64 | 27 | 2 | 3 | 30 |
3,560 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/modeling_m2m_100.py | transformers.models.m2m_100.modeling_m2m_100.M2M100EncoderLayer | from torch import nn
import torch
from ...activations import ACT2FN
from .configuration_m2m_100 import M2M100Config
from ...modeling_layers import GradientCheckpointingLayer
class M2M100EncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: M2M100Config):
super().__init__()
self.embe... |
class M2M100EncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: M2M100Config):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, layer_head_mask: torch.Tensor, output_attentions: bool=False) -> torch.Tensor:
'''
Args:
hidden... | 3 | 1 | 33 | 3 | 25 | 6 | 2 | 0.22 | 1 | 4 | 1 | 0 | 2 | 9 | 2 | 12 | 68 | 7 | 50 | 22 | 41 | 11 | 32 | 16 | 29 | 3 | 1 | 1 | 4 |
3,561 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/modeling_m2m_100.py | transformers.models.m2m_100.modeling_m2m_100.M2M100ForConditionalGeneration | from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from .configuration_m2m_100 import M2M100Config
from torch import nn
from ...generation import GenerationMixin
import torch
from ...modeling_outputs im... | @auto_docstring(custom_intro='\n The M2M100 Model with a language modeling head. Can be used for summarization.\n ')
class M2M100ForConditionalGeneration(M2M100PreTrainedModel, GenerationMixin):
def __init__(self, config: M2M100Config):
pass
def get_encoder(self):
pass
def get_decod... | 7 | 1 | 14 | 1 | 12 | 1 | 2 | 0.1 | 2 | 7 | 3 | 0 | 6 | 2 | 7 | 8 | 112 | 14 | 89 | 39 | 59 | 9 | 37 | 19 | 29 | 7 | 2 | 2 | 14 |
3,562 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/modeling_m2m_100.py | transformers.models.m2m_100.modeling_m2m_100.M2M100Model | from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
import math
import torch
from typing import Callable, Optional, Union
from .configuration_m2m_100 import M2M100Config
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
from ...modeling_outputs import B... | @auto_docstring
class M2M100Model(M2M100PreTrainedModel):
def __init__(self, config: M2M100Config):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, value):
pass
def _tie_weights(self):
pass
def get_encoder(self):
pass
@auto_do... | 9 | 1 | 15 | 1 | 13 | 0 | 3 | 0.03 | 1 | 9 | 6 | 0 | 7 | 3 | 7 | 8 | 118 | 15 | 100 | 33 | 69 | 3 | 38 | 15 | 30 | 10 | 2 | 1 | 19 |
3,563 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/modeling_m2m_100.py | transformers.models.m2m_100.modeling_m2m_100.M2M100PreTrainedModel | from ...modeling_attn_mask_utils import AttentionMaskConverter, _prepare_4d_attention_mask, _prepare_4d_attention_mask_for_sdpa
import torch
from typing import Callable, Optional, Union
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...utils import auto_docstring, is_torch_flex_attn_available,... | @auto_docstring
class M2M100PreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
pass
def _update_full_mask(self, attention_mask: Union[torch.Tensor, None], inputs_embeds: torch.Tensor):
pass
def _update_causal_mask(self, attention_mask: Optional[Union[torch.Tensor, 'BlockMa... | 8 | 1 | 10 | 0 | 10 | 0 | 5 | 0 | 1 | 0 | 0 | 4 | 1 | 0 | 1 | 1 | 18 | 1 | 17 | 9 | 15 | 0 | 16 | 9 | 14 | 5 | 1 | 2 | 5 |
3,564 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/modeling_m2m_100.py | transformers.models.m2m_100.modeling_m2m_100.M2M100ScaledWordEmbedding | from torch import nn
import torch
from typing import Callable, Optional, Union
class M2M100ScaledWordEmbedding(nn.Embedding):
"""
This module overrides nn.Embeddings' forward by multiplying with embeddings scale.
"""
def __init__(self, num_embeddings: int, embedding_dim: int, padding_idx: int, embed_s... |
class M2M100ScaledWordEmbedding(nn.Embedding):
'''
This module overrides nn.Embeddings' forward by multiplying with embeddings scale.
'''
def __init__(self, num_embeddings: int, embedding_dim: int, padding_idx: int, embed_scale: Optional[float]=1.0):
pass
def forward(self, input_ids: torc... | 3 | 1 | 3 | 0 | 3 | 0 | 1 | 0.5 | 1 | 4 | 0 | 0 | 2 | 1 | 2 | 2 | 11 | 2 | 6 | 4 | 3 | 3 | 6 | 4 | 3 | 1 | 1 | 0 | 2 |
3,565 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/modeling_m2m_100.py | transformers.models.m2m_100.modeling_m2m_100.M2M100SinusoidalPositionalEmbedding | from torch import nn
from typing import Callable, Optional, Union
import math
import torch
class M2M100SinusoidalPositionalEmbedding(nn.Module):
"""This module produces sinusoidal positional embeddings of any length."""
def __init__(self, num_positions: int, embedding_dim: int, padding_idx: Optional[int]=None... |
class M2M100SinusoidalPositionalEmbedding(nn.Module):
'''This module produces sinusoidal positional embeddings of any length.'''
def __init__(self, num_positions: int, embedding_dim: int, padding_idx: Optional[int]=None):
pass
def make_weights(self, num_embeddings: int, embedding_dim: int, paddin... | 11 | 4 | 13 | 2 | 9 | 3 | 2 | 0.34 | 1 | 3 | 0 | 0 | 4 | 3 | 5 | 15 | 76 | 13 | 47 | 22 | 37 | 16 | 38 | 18 | 32 | 3 | 1 | 1 | 10 |
3,566 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/m2m_100/tokenization_m2m_100.py | transformers.models.m2m_100.tokenization_m2m_100.M2M100Tokenizer | from typing import Any, Optional, Union
import os
from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer
from ...utils.import_utils import requires
from shutil import copyfile
from pathlib import Path
@requires(backends=('sentencepiece',))
class M2M100Tokenizer(PreTrainedTokenizer):
"""
Construct... | @requires(backends=('sentencepiece',))
class M2M100Tokenizer(PreTrainedTokenizer):
'''
Construct an M2M100 tokenizer. Based on [SentencePiece](https://github.com/google/sentencepiece).
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
thi... | 27 | 8 | 10 | 1 | 8 | 2 | 2 | 0.47 | 1 | 11 | 1 | 0 | 22 | 17 | 22 | 111 | 317 | 53 | 179 | 93 | 127 | 85 | 127 | 63 | 104 | 6 | 3 | 2 | 40 |
3,567 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba/configuration_mamba.py | transformers.models.mamba.configuration_mamba.MambaConfig | import math
from ...configuration_utils import PretrainedConfig
class MambaConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`MambaModel`]. It is used to instantiate a MAMBA
model according to the specified arguments, defining the model architecture. Instantiati... |
class MambaConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`MambaModel`]. It is used to instantiate a MAMBA
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar co... | 2 | 1 | 55 | 1 | 54 | 0 | 2 | 1.14 | 1 | 2 | 0 | 0 | 1 | 25 | 1 | 1 | 132 | 12 | 56 | 55 | 27 | 64 | 29 | 28 | 27 | 2 | 1 | 0 | 2 |
3,568 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba/modeling_mamba.py | transformers.models.mamba.modeling_mamba.MambaBlock | from typing import Any, Optional, Union
import torch
from ...modeling_layers import GradientCheckpointingLayer
class MambaBlock(GradientCheckpointingLayer):
def __init__(self, config, layer_idx):
super().__init__()
self.config = config
self.layer_idx = layer_idx
self.residual_in_fp... |
class MambaBlock(GradientCheckpointingLayer):
def __init__(self, config, layer_idx):
pass
def forward(self, hidden_states, cache_params: Optional[MambaCache]=None, cache_position: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.LongTensor]=None):
pass | 3 | 0 | 12 | 1 | 12 | 0 | 2 | 0 | 1 | 4 | 3 | 0 | 2 | 5 | 2 | 12 | 26 | 2 | 24 | 15 | 15 | 0 | 16 | 9 | 13 | 2 | 1 | 1 | 3 |
3,569 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba/modeling_mamba.py | transformers.models.mamba.modeling_mamba.MambaForCausalLM | from ...utils import ModelOutput, auto_docstring, logging
import torch
from torch.nn import CrossEntropyLoss
from torch import nn
from ...generation import GenerationMixin
from typing import Any, Optional, Union
@auto_docstring(custom_intro='\n The MAMBA Model transformer with a language modeling head on top (linea... | @auto_docstring(custom_intro='\n The MAMBA Model transformer with a language modeling head on top (linear layer with weights tied to the input\n embeddings).\n ')
class MambaForCausalLM(MambaPreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
def get_input_embeddings(self):
... | 9 | 1 | 17 | 2 | 13 | 2 | 2 | 0.15 | 2 | 10 | 3 | 0 | 8 | 2 | 8 | 9 | 151 | 20 | 115 | 46 | 77 | 17 | 53 | 22 | 44 | 6 | 2 | 3 | 19 |
3,570 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba/modeling_mamba.py | transformers.models.mamba.modeling_mamba.MambaMixer | from typing import Any, Optional, Union
import torch
from ...utils.import_utils import is_causal_conv1d_available, is_kernels_available, is_mamba_ssm_available, is_mambapy_available
from .configuration_mamba import MambaConfig
from torch import nn
from ...activations import ACT2FN
class MambaMixer(nn.Module):
"""
... |
class MambaMixer(nn.Module):
'''
Compute ∆, A, B, C, and D the state space parameters and compute the `contextualized_states`.
A, D are input independent (see Mamba paper [1] Section 3.5.2 "Interpretation of A" for why A isn't selective)
∆, B, C are input-dependent (this is a key difference between Mam... | 6 | 1 | 62 | 6 | 51 | 10 | 7 | 0.24 | 1 | 7 | 2 | 0 | 4 | 19 | 4 | 14 | 261 | 28 | 204 | 67 | 187 | 49 | 111 | 55 | 106 | 11 | 1 | 3 | 26 |
3,571 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba/modeling_mamba.py | transformers.models.mamba.modeling_mamba.MambaModel | import torch
from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
from typing import Any, Optional, Union
@auto_docstring
class MambaModel(MambaPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.embeddings = nn.Embedding(config.vocab_size, config.... | @auto_docstring
class MambaModel(MambaPreTrainedModel):
def __init__(self, config):
pass
def load_hook(self, state_dict, prefix, *args):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, new_embeddings):
pass
@auto_docstring
def forward(... | 8 | 1 | 19 | 2 | 16 | 1 | 5 | 0.06 | 1 | 9 | 4 | 0 | 5 | 5 | 5 | 6 | 106 | 16 | 86 | 26 | 64 | 5 | 48 | 14 | 42 | 18 | 2 | 2 | 24 |
3,572 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba/modeling_mamba.py | transformers.models.mamba.modeling_mamba.MambaOutput | from typing import Any, Optional, Union
import torch
from dataclasses import dataclass
from ...utils import ModelOutput, auto_docstring, logging
@dataclass
@auto_docstring(custom_intro='\n Class for the MAMBA model outputs.\n ')
class MambaOutput(ModelOutput):
"""
cache_params (`MambaCache`):
The... | @dataclass
@auto_docstring(custom_intro='\n Class for the MAMBA model outputs.\n ')
class MambaOutput(ModelOutput):
'''
cache_params (`MambaCache`):
The state of the model at the last time step. Can be used in a forward method with the next `input_ids` to
avoid providing the old `input_ids... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 22 | 4 | 4 | 4 | 3 | 14 | 4 | 4 | 3 | 0 | 1 | 0 | 0 |
3,573 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba/modeling_mamba.py | transformers.models.mamba.modeling_mamba.MambaPreTrainedModel | from .configuration_mamba import MambaConfig
from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
import math
import torch
from ...modeling_utils import PreTrainedModel
@auto_docstring
class MambaPreTrainedModel(PreTrainedModel):
config: MambaConfig
base_model_prefix = 'backbone'
... | @auto_docstring
class MambaPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights.'''
pass | 3 | 1 | 46 | 4 | 30 | 12 | 11 | 0.44 | 1 | 1 | 1 | 2 | 1 | 0 | 1 | 1 | 58 | 6 | 36 | 11 | 34 | 16 | 30 | 11 | 28 | 11 | 1 | 4 | 11 |
3,574 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba/modeling_mamba.py | transformers.models.mamba.modeling_mamba.MambaRMSNorm | from torch import nn
import torch
class MambaRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
"""
MambaRMSNorm is equivalent to T5LayerNorm and LlamaRMSNorm
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.variance_epsil... |
class MambaRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
'''
MambaRMSNorm is equivalent to T5LayerNorm and LlamaRMSNorm
'''
pass
def forward(self, hidden_states):
pass
def extra_repr(self):
pass | 4 | 1 | 5 | 0 | 4 | 1 | 1 | 0.23 | 1 | 1 | 0 | 0 | 3 | 2 | 3 | 13 | 18 | 2 | 13 | 8 | 9 | 3 | 13 | 8 | 9 | 1 | 1 | 0 | 3 |
3,575 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba2/configuration_mamba2.py | transformers.models.mamba2.configuration_mamba2.Mamba2Config | from ...configuration_utils import PretrainedConfig
import math
class Mamba2Config(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`Mamba2Model`]. It is used to instantiate a MAMBA2
model according to the specified arguments, defining the model architecture. Instanti... |
class Mamba2Config(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`Mamba2Model`]. It is used to instantiate a MAMBA2
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar... | 2 | 1 | 70 | 2 | 68 | 0 | 2 | 1.03 | 1 | 2 | 0 | 0 | 1 | 28 | 1 | 1 | 155 | 13 | 70 | 62 | 37 | 72 | 33 | 31 | 31 | 2 | 1 | 0 | 2 |
3,576 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba2/modeling_mamba2.py | transformers.models.mamba2.modeling_mamba2.Mamba2Block | from typing import Optional, Union
from ...modeling_layers import GradientCheckpointingLayer
import torch
class Mamba2Block(GradientCheckpointingLayer):
def __init__(self, config, layer_idx):
super().__init__()
self.config = config
self.layer_idx = layer_idx
self.residual_in_fp32 =... |
class Mamba2Block(GradientCheckpointingLayer):
def __init__(self, config, layer_idx):
pass
def forward(self, hidden_states, cache_params: Optional[Mamba2Cache]=None, cache_position: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.Tensor]=None):
pass | 3 | 0 | 12 | 1 | 12 | 0 | 2 | 0 | 1 | 5 | 3 | 0 | 2 | 5 | 2 | 12 | 26 | 2 | 24 | 15 | 15 | 0 | 16 | 9 | 13 | 2 | 1 | 1 | 3 |
3,577 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba2/modeling_mamba2.py | transformers.models.mamba2.modeling_mamba2.Mamba2Cache | from typing import Optional, Union
import torch
from .configuration_mamba2 import Mamba2Config
class Mamba2Cache:
"""
Arguments:
config: Mamba2Config
batch_size: int
dtype: torch.dtype
device: torch.device
Attributes:
dtype: (`torch.dtype`):
The default ... |
class Mamba2Cache:
'''
Arguments:
config: Mamba2Config
batch_size: int
dtype: torch.dtype
device: torch.device
Attributes:
dtype: (`torch.dtype`):
The default `dtype` used to initializing the cache.
conv_kernel_size: (`int`):
Model's c... | 5 | 1 | 11 | 0 | 11 | 0 | 1 | 0.6 | 0 | 5 | 1 | 0 | 4 | 9 | 4 | 4 | 75 | 6 | 43 | 18 | 34 | 26 | 23 | 14 | 18 | 2 | 0 | 1 | 5 |
3,578 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba2/modeling_mamba2.py | transformers.models.mamba2.modeling_mamba2.Mamba2ForCausalLM | import torch
from ...utils import ModelOutput, auto_docstring, logging
from typing import Optional, Union
from ...generation import GenerationMixin
from torch import nn
@auto_docstring(custom_intro='\n The MAMBA2 Model transformer with a language modeling head on top (linear layer with weights not tied to the input... | @auto_docstring(custom_intro='\n The MAMBA2 Model transformer with a language modeling head on top (linear layer with weights not tied to the input\n embeddings).\n ')
class Mamba2ForCausalLM(Mamba2PreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
def get_input_embeddings(se... | 8 | 1 | 17 | 1 | 13 | 2 | 2 | 0.17 | 2 | 7 | 3 | 0 | 7 | 2 | 7 | 8 | 131 | 16 | 99 | 42 | 64 | 17 | 45 | 20 | 37 | 6 | 2 | 3 | 16 |
3,579 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba2/modeling_mamba2.py | transformers.models.mamba2.modeling_mamba2.Mamba2Mixer | from .configuration_mamba2 import Mamba2Config
from ...activations import ACT2FN
import torch
from typing import Optional, Union
from torch import nn
class Mamba2Mixer(nn.Module):
"""
Compute ∆, A, B, C, and D the state space parameters and compute the `contextualized_states`.
A, D are input independent (s... |
class Mamba2Mixer(nn.Module):
'''
Compute ∆, A, B, C, and D the state space parameters and compute the `contextualized_states`.
A, D are input independent (see Mamba paper [1] Section 3.5.2 "Interpretation of A" for why A isn't selective)
∆, B, C are input-dependent (this is a key difference between Ma... | 5 | 1 | 108 | 15 | 76 | 19 | 5 | 0.28 | 1 | 7 | 3 | 0 | 4 | 27 | 4 | 14 | 443 | 63 | 306 | 103 | 289 | 85 | 181 | 91 | 176 | 8 | 1 | 3 | 20 |
3,580 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba2/modeling_mamba2.py | transformers.models.mamba2.modeling_mamba2.Mamba2Model | import torch
from typing import Optional, Union
from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring
class Mamba2Model(Mamba2PreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.embeddings = nn.Embedding(config.vocab_size, config.hid... | @auto_docstring
class Mamba2Model(Mamba2PreTrainedModel):
def __init__(self, config):
pass
def load_hook(self, state_dict, prefix, *args):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, new_embeddings):
pass
@auto_docstring
def forwar... | 8 | 1 | 19 | 2 | 16 | 1 | 5 | 0.06 | 1 | 10 | 4 | 0 | 5 | 5 | 5 | 6 | 107 | 16 | 87 | 27 | 64 | 5 | 48 | 14 | 42 | 18 | 2 | 2 | 24 |
3,581 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba2/modeling_mamba2.py | transformers.models.mamba2.modeling_mamba2.Mamba2Output | from dataclasses import dataclass
import torch
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
@dataclass
@auto_docstring(custom_intro='\n Class for the MAMBA2 model outputs.\n ')
class Mamba2Output(ModelOutput):
"""
cache_params (`Mamba2Cache`):
The s... | @dataclass
@auto_docstring(custom_intro='\n Class for the MAMBA2 model outputs.\n ')
class Mamba2Output(ModelOutput):
'''
cache_params (`Mamba2Cache`):
The state of the model at the last time step. Can be used in a forward method with the next `input_ids` to
avoid providing the old `input_... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 22 | 4 | 4 | 4 | 3 | 14 | 4 | 4 | 3 | 0 | 1 | 0 | 0 |
3,582 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba2/modeling_mamba2.py | transformers.models.mamba2.modeling_mamba2.Mamba2PreTrainedModel | import torch
from ...modeling_utils import PreTrainedModel
from ...utils import ModelOutput, auto_docstring, logging
import math
from .configuration_mamba2 import Mamba2Config
from torch import nn
@auto_docstring
class Mamba2PreTrainedModel(PreTrainedModel):
config: Mamba2Config
base_model_prefix = 'backbone'
... | @auto_docstring
class Mamba2PreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights.'''
pass | 3 | 1 | 41 | 4 | 25 | 12 | 9 | 0.52 | 1 | 1 | 1 | 2 | 1 | 0 | 1 | 1 | 53 | 6 | 31 | 10 | 29 | 16 | 26 | 10 | 24 | 9 | 1 | 4 | 9 |
3,583 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba2/modeling_mamba2.py | transformers.models.mamba2.modeling_mamba2.Mamba2RMSNorm | from torch import nn
import torch
class Mamba2RMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
"""
Mamba2RMSNorm is equivalent to T5LayerNorm and LlamaRMSNorm
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.variance_eps... |
class Mamba2RMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
'''
Mamba2RMSNorm is equivalent to T5LayerNorm and LlamaRMSNorm
'''
pass
def forward(self, hidden_states):
pass | 3 | 1 | 7 | 0 | 5 | 2 | 1 | 0.27 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 15 | 1 | 11 | 7 | 8 | 3 | 11 | 7 | 8 | 1 | 1 | 0 | 2 |
3,584 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mamba2/modeling_mamba2.py | transformers.models.mamba2.modeling_mamba2.MambaRMSNormGated | import torch
from torch import nn
class MambaRMSNormGated(torch.nn.Module):
def __init__(self, hidden_size, eps=1e-06):
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.variance_epsilon = eps
def forward(self, hidden_states, gate=None):
input_dtype =... |
class MambaRMSNormGated(torch.nn.Module):
def __init__(self, hidden_size, eps=1e-06):
pass
def forward(self, hidden_states, gate=None):
pass | 3 | 0 | 7 | 1 | 6 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 16 | 3 | 13 | 7 | 10 | 0 | 13 | 7 | 10 | 2 | 1 | 1 | 3 |
3,585 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/configuration_marian.py | transformers.models.marian.configuration_marian.MarianConfig | from ...configuration_utils import PretrainedConfig
class MarianConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`MarianModel`]. It is used to instantiate an
Marian model according to the specified arguments, defining the model architecture. Instantiating a con... |
class MarianConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`MarianModel`]. It is used to instantiate an
Marian model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a simila... | 2 | 1 | 58 | 0 | 58 | 1 | 1 | 1.02 | 1 | 1 | 0 | 0 | 1 | 21 | 1 | 1 | 134 | 10 | 62 | 54 | 32 | 63 | 27 | 26 | 25 | 1 | 1 | 0 | 1 |
3,586 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/configuration_marian.py | transformers.models.marian.configuration_marian.MarianOnnxConfig | from ...onnx.utils import compute_effective_axis_dimension
from typing import Any
from collections import OrderedDict
from collections.abc import Mapping
from ... import PreTrainedTokenizer
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeq2SeqConfigWithPast
from ...utils import is_torch_available, logging
cl... |
class MarianOnnxConfig(OnnxSeq2SeqConfigWithPast):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
pass
@property
def outputs(self) -> Mapping[str, Mapping[int, str]]:
pass
def _generate_dummy_inputs_for_default_and_seq2seq_lm(self, tokenizer: PreTrainedTokenizer, b... | 12 | 0 | 26 | 2 | 23 | 1 | 4 | 0.08 | 1 | 10 | 0 | 0 | 8 | 1 | 8 | 8 | 226 | 21 | 190 | 75 | 148 | 15 | 90 | 43 | 79 | 8 | 1 | 3 | 28 |
3,587 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/convert_marian_tatoeba_to_pytorch.py | transformers.models.marian.convert_marian_tatoeba_to_pytorch.TatoebaConverter | import datetime
import yaml
from transformers.models.marian.convert_marian_to_pytorch import FRONT_MATTER_TEMPLATE, convert, convert_opus_name_to_hf_name, download_and_unzip, get_system_metadata
import os
from tqdm import tqdm
import re
import json
from pathlib import Path
class TatoebaConverter:
"""
Convert T... |
class TatoebaConverter:
'''
Convert Tatoeba-Challenge models to huggingface format.
Steps:
1. Convert numpy state dict to hf format (same code as OPUS-MT-Train conversion).
2. Rename opus model to huggingface format. This means replace each alpha3 code with an alpha2 code if a unique
... | 13 | 2 | 23 | 2 | 20 | 1 | 5 | 0.12 | 0 | 7 | 0 | 0 | 9 | 4 | 10 | 10 | 277 | 35 | 220 | 73 | 204 | 26 | 178 | 71 | 163 | 21 | 0 | 3 | 51 |
3,588 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/convert_marian_to_pytorch.py | transformers.models.marian.convert_marian_to_pytorch.OpusState | import torch
from torch import nn
import warnings
from transformers import MarianConfig, MarianMTModel, MarianTokenizer
import numpy as np
class OpusState:
def __init__(self, source_dir, eos_token_id=0):
npz_path = find_model_file(source_dir)
self.state_dict = np.load(npz_path)
cfg = load_... |
class OpusState:
def __init__(self, source_dir, eos_token_id=0):
pass
def _check_layer_entries(self):
pass
@property
def extra_keys(self):
pass
def sub_keys(self, layer_prefix):
pass
def load_tokenizer(self):
pass
def load_marian_model(self) -> M... | 8 | 0 | 28 | 3 | 24 | 2 | 5 | 0.07 | 0 | 8 | 0 | 0 | 6 | 14 | 6 | 6 | 173 | 20 | 144 | 35 | 136 | 10 | 98 | 34 | 91 | 10 | 0 | 2 | 28 |
3,589 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianAttention | from typing import Callable, Optional, Union
from torch import nn
import torch
from ...processing_utils import Unpack
from .configuration_marian import MarianConfig
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from ...modeling... |
class MarianAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, embed_dim: int, num_heads: int, dropout: float=0.0, is_decoder: bool=False, bias: bool=True, is_causal: bool=False, config: Optional[MarianConfig]=None, layer_idx: Optional[int]=None):
... | 4 | 2 | 50 | 7 | 35 | 8 | 5 | 0.24 | 1 | 7 | 1 | 0 | 3 | 12 | 3 | 13 | 156 | 23 | 107 | 44 | 86 | 26 | 68 | 27 | 64 | 12 | 1 | 2 | 15 |
3,590 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianDecoder | from typing import Callable, Optional, Union
import math
from torch import nn
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, Seq2SeqLMOutpu... |
class MarianDecoder(MarianPreTrainedModel):
'''
Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`MarianDecoderLayer`]
Args:
config: MarianConfig
embed_tokens (nn.Embedding): output embedding
'''
def __init__(self, config: MarianConfig, embed_token... | 3 | 2 | 59 | 8 | 35 | 16 | 10 | 0.5 | 1 | 12 | 4 | 0 | 4 | 9 | 4 | 6 | 246 | 38 | 139 | 42 | 120 | 69 | 74 | 28 | 69 | 36 | 2 | 3 | 41 |
3,591 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianDecoderLayer | from typing import Callable, Optional, Union
from torch import nn
import torch
from ...modeling_layers import GradientCheckpointingLayer
from .configuration_marian import MarianConfig
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...utils.deprecation import deprecate_kwarg
from ...activations... |
class MarianDecoderLayer(GradientCheckpointingLayer):
def __init__(self, config: MarianConfig, layer_idx: Optional[int]=None):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=N... | 4 | 1 | 58 | 6 | 40 | 13 | 4 | 0.31 | 1 | 4 | 1 | 0 | 2 | 11 | 2 | 12 | 118 | 12 | 81 | 32 | 67 | 25 | 44 | 21 | 41 | 6 | 1 | 1 | 7 |
3,592 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianDecoderWrapper | class MarianDecoderWrapper(MarianPreTrainedModel):
"""
This wrapper class is a helper class to correctly load pretrained checkpoints when the causal language model is
used in combination with the [`EncoderDecoderModel`] framework.
"""
def __init__(self, config):
super().__init__(config)
... | class MarianDecoderWrapper(MarianPreTrainedModel):
'''
This wrapper class is a helper class to correctly load pretrained checkpoints when the causal language model is
used in combination with the [`EncoderDecoderModel`] framework.
'''
def __init__(self, config):
pass
def forward(self, ... | 3 | 1 | 3 | 0 | 3 | 0 | 1 | 0.67 | 1 | 2 | 1 | 0 | 2 | 1 | 2 | 4 | 12 | 2 | 6 | 4 | 3 | 4 | 6 | 4 | 3 | 1 | 2 | 0 | 2 |
3,593 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianEncoder | import torch
from .configuration_marian import MarianConfig
from typing import Callable, Optional, Union
import math
from torch import nn
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput
class MarianEncode... |
class MarianEncoder(MarianPreTrainedModel):
'''
Transformer encoder consisting of *config.encoder_layers* self attention layers. Each layer is a
[`MarianEncoderLayer`].
Args:
config: MarianConfig
embed_tokens (nn.Embedding): output embedding
'''
def __init__(self, config: Maria... | 3 | 2 | 39 | 6 | 24 | 9 | 7 | 0.45 | 1 | 11 | 4 | 0 | 4 | 9 | 4 | 6 | 168 | 28 | 97 | 33 | 83 | 44 | 63 | 24 | 58 | 23 | 2 | 3 | 28 |
3,594 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianEncoderLayer | from typing import Callable, Optional, Union
from torch import nn
import torch
from ...modeling_layers import GradientCheckpointingLayer
from .configuration_marian import MarianConfig
from ...activations import ACT2FN
class MarianEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: MarianConfig, l... |
class MarianEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: MarianConfig, layer_idx: Optional[int]=None):
pass
def forward(self, hidden_states: torch.FloatTensor, attention_mask: torch.FloatTensor, layer_head_mask: torch.FloatTensor, output_attentions: Optional[bool]=False) -> tu... | 3 | 1 | 33 | 3 | 25 | 6 | 2 | 0.22 | 1 | 3 | 1 | 0 | 2 | 9 | 2 | 12 | 68 | 7 | 50 | 22 | 41 | 11 | 32 | 16 | 29 | 3 | 1 | 1 | 4 |
3,595 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianForCausalLM | from typing import Callable, Optional, Union
from torch.nn import CrossEntropyLoss
from torch import nn
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
from ...generation import GenerationMixin
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastA... |
class MarianForCausalLM(MarianPreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, value):
pass
def set_decoder(self, decoder):
pass
def get_decoder(self):
pass
@auto_... | 8 | 1 | 19 | 3 | 9 | 8 | 2 | 0.84 | 2 | 6 | 2 | 0 | 8 | 2 | 9 | 11 | 186 | 33 | 83 | 37 | 56 | 70 | 42 | 20 | 32 | 7 | 2 | 1 | 16 |
3,596 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianMTModel | from typing import Callable, Optional, Union
from torch.nn import CrossEntropyLoss
from torch import nn
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
from ...generation import GenerationMixin
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastA... | @auto_docstring(custom_intro='\n The Marian Model with a language modeling head. Can be used for summarization.\n ')
class MarianMTModel(MarianPreTrainedModel, GenerationMixin):
def __init__(self, config: MarianConfig):
pass
def get_encoder(self):
pass
def get_decoder(self):
... | 14 | 2 | 15 | 2 | 12 | 2 | 3 | 0.14 | 2 | 10 | 4 | 0 | 12 | 4 | 13 | 15 | 228 | 36 | 168 | 69 | 130 | 24 | 99 | 46 | 85 | 8 | 2 | 2 | 34 |
3,597 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianModel | from .configuration_marian import MarianConfig
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Callable, Optional, Union
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
from ...modeling_outputs import BaseModelOutput, BaseModelO... | @auto_docstring
class MarianModel(MarianPreTrainedModel):
def __init__(self, config: MarianConfig):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, value):
pass
def get_decoder_input_embeddings(self):
pass
def set_decoder_input_embeddings... | 11 | 1 | 19 | 2 | 14 | 3 | 3 | 0.22 | 1 | 10 | 5 | 0 | 9 | 3 | 9 | 11 | 181 | 28 | 126 | 38 | 97 | 28 | 58 | 20 | 48 | 10 | 2 | 1 | 24 |
3,598 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianPreTrainedModel | from typing import Callable, Optional, Union
from ...modeling_attn_mask_utils import AttentionMaskConverter, _prepare_4d_attention_mask, _prepare_4d_attention_mask_for_sdpa
from torch import nn
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
import torch
from .config... | @auto_docstring
class MarianPreTrainedModel(PreTrainedModel):
def _init_weights(self, module: Union[nn.Linear, nn.Embedding, MarianSinusoidalPositionalEmbedding]):
pass
@property
def dummy_inputs(self):
pass
def _update_full_mask(self, attention_mask: Union[torch.Tensor, None], inputs_... | 10 | 1 | 11 | 0 | 11 | 0 | 4 | 0 | 1 | 1 | 1 | 6 | 2 | 0 | 2 | 2 | 28 | 2 | 26 | 11 | 22 | 0 | 19 | 10 | 16 | 6 | 1 | 2 | 7 |
3,599 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/modeling_marian.py | transformers.models.marian.modeling_marian.MarianSinusoidalPositionalEmbedding | from typing import Callable, Optional, Union
import numpy as np
from torch import nn
import torch
class MarianSinusoidalPositionalEmbedding(nn.Embedding):
"""This module produces sinusoidal positional embeddings of any length."""
def __init__(self, num_positions: int, embedding_dim: int, padding_idx: Optional... |
class MarianSinusoidalPositionalEmbedding(nn.Embedding):
'''This module produces sinusoidal positional embeddings of any length.'''
def __init__(self, num_positions: int, embedding_dim: int, padding_idx: Optional[int]=None) -> None:
pass
def _init_weight(self):
'''
Identical to th... | 5 | 3 | 8 | 0 | 7 | 2 | 1 | 0.3 | 1 | 4 | 0 | 0 | 2 | 1 | 3 | 3 | 32 | 3 | 23 | 12 | 17 | 7 | 17 | 10 | 13 | 2 | 1 | 0 | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.