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
1,800
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py
transformers.models.deprecated.mctct.modeling_mctct.MCTCTOutput
from torch import nn class MCTCTOutput(nn.Module): def __init__(self, config): super().__init__() self.dense = nn.Linear(config.intermediate_size, config.hidden_size, bias=False) self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps) self.dropout = nn.Dropout(...
class MCTCTOutput(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
1,801
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py
transformers.models.deprecated.mctct.modeling_mctct.MCTCTPreTrainedModel
from .configuration_mctct import MCTCTConfig from ....modeling_utils import PreTrainedModel from torch import nn import torch class MCTCTPreTrainedModel(PreTrainedModel): """ An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models. """ ...
class MCTCTPreTrainedModel(PreTrainedModel): ''' An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models. ''' def _init_weights(self, module): '''Initialize the weights''' pass def _get_feat_extract_output_lengths...
4
3
18
1
13
4
4
0.33
1
3
1
3
3
0
3
132
67
7
45
14
41
15
38
14
34
9
2
2
13
1,802
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py
transformers.models.deprecated.mctct.modeling_mctct.MCTCTSelfAttention
import torch import math from torch import nn class MCTCTSelfAttention(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 MCTCTSelfAttention(nn.Module): def __init__(self, config): pass def transpose_for_scores(self, x): pass def reshape_fortran(self, x, shape): pass def relative_position_embedding_rotate(self, scores): pass def forward(self, hidden_states, attention_mask=Non...
6
0
20
5
12
3
2
0.25
1
4
0
0
5
10
5
15
106
29
63
35
51
16
54
29
48
4
1
1
10
1,803
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py
transformers.models.deprecated.mctct.modeling_mctct.MCTCTSelfOutput
from torch import nn class MCTCTSelfOutput(nn.Module): def __init__(self, config): super().__init__() self.config = config self.dense = nn.Linear(config.hidden_size, config.hidden_size, bias=False) self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps) ...
class MCTCTSelfOutput(nn.Module): def __init__(self, config): pass def forward(self, hidden_states, input_tensor): pass
3
0
6
0
6
0
1
0
1
1
0
0
2
4
2
12
13
1
12
7
9
0
12
7
9
1
1
0
2
1,804
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/processing_mctct.py
transformers.models.deprecated.mctct.processing_mctct.MCTCTProcessor
from contextlib import contextmanager import warnings from ....processing_utils import ProcessorMixin class MCTCTProcessor(ProcessorMixin): """ Constructs a MCTCT processor which wraps a MCTCT feature extractor and a MCTCT tokenizer into a single processor. [`MCTCTProcessor`] offers all the functionalitie...
class MCTCTProcessor(ProcessorMixin): ''' Constructs a MCTCT processor which wraps a MCTCT feature extractor and a MCTCT tokenizer into a single processor. [`MCTCTProcessor`] offers all the functionalities of [`MCTCTFeatureExtractor`] and [`AutoTokenizer`]. See the [`~MCTCTProcessor.__call__`] and [`~M...
7
5
16
1
11
4
3
0.51
1
2
0
0
6
2
6
23
119
16
68
19
60
35
58
18
51
9
2
1
20
1,805
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/configuration_mega.py
transformers.models.deprecated.mega.configuration_mega.MegaConfig
from ....configuration_utils import PretrainedConfig class MegaConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`MegaModel`]. It is used to instantiate a Mega model according to the specified arguments, defining the model architecture. Instantiating a configura...
class MegaConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`MegaModel`]. It is used to instantiate a Mega model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar confi...
2
1
78
1
77
1
1
1.38
1
1
0
0
1
35
1
33
198
11
79
78
37
109
39
38
37
1
2
0
1
1,806
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/configuration_mega.py
transformers.models.deprecated.mega.configuration_mega.MegaOnnxConfig
from collections import OrderedDict from ....onnx import OnnxConfig from collections.abc import Mapping class MegaOnnxConfig(OnnxConfig): @property def inputs(self) -> Mapping[str, Mapping[int, str]]: if self.task == 'multiple-choice': dynamic_axis = {0: 'batch', 1: 'choice', 2: 'sequence'...
class MegaOnnxConfig(OnnxConfig): @property def inputs(self) -> Mapping[str, Mapping[int, str]]: pass
3
0
11
0
11
0
2
0
1
3
0
0
1
0
1
40
13
0
13
4
10
0
6
3
4
2
5
1
2
1,807
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/convert_mega_original_pytorch_checkpoint_to_pytorch.py
transformers.models.deprecated.mega.convert_mega_original_pytorch_checkpoint_to_pytorch.MegaLM
from torch import nn import torch class MegaLM(nn.Module): """The base class for our Mega encoder - given input IDs, embed text and return encoder output""" def __init__(self, mega_args, depth, vocab_size): super().__init__() self.mega_args = mega_args self.embedding_layer = nn.Embeddi...
class MegaLM(nn.Module): '''The base class for our Mega encoder - given input IDs, embed text and return encoder output''' def __init__(self, mega_args, depth, vocab_size): pass def forward(self, input_ids, attention_mask, batch_first=True, ignore_mask_value=0): ''' Code for a for...
3
2
22
3
9
10
3
1.05
1
2
0
0
2
4
2
12
47
8
19
9
16
20
18
9
15
5
1
1
6
1,808
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/convert_mega_original_pytorch_checkpoint_to_pytorch.py
transformers.models.deprecated.mega.convert_mega_original_pytorch_checkpoint_to_pytorch.OriginalMegaForMaskedLM
from torch import nn class OriginalMegaForMaskedLM(nn.Module): """A wrapper class for doing masked language modeling with Mega""" def __init__(self, mega_args, depth, vocab_size): super().__init__() self.mega = MegaLM(mega_args, depth, vocab_size) self.mlm_head = nn.Linear(mega_args.en...
class OriginalMegaForMaskedLM(nn.Module): '''A wrapper class for doing masked language modeling with Mega''' def __init__(self, mega_args, depth, vocab_size): pass def forward(self, input_ids, attention_mask, batch_first=True, ignore_mask_value=0): ''' Perform a forward pass throu...
3
2
8
1
4
3
1
0.78
1
2
1
0
2
3
2
12
19
3
9
7
6
7
9
7
6
1
1
0
2
1,809
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaBlock
from torch import nn import torch.nn.functional as F from ....cache_utils import Cache from .configuration_mega import MegaConfig import torch from ....utils.deprecation import deprecate_kwarg from typing import Optional, Union class MegaBlock(nn.Module): def __init__(self, config: MegaConfig): super().__...
class MegaBlock(nn.Module): def __init__(self, config: MegaConfig): 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.LongTensor]=None, causal_mask: Optional[torch.LongTensor]=None, enco...
4
1
73
7
36
31
9
0.85
1
8
4
0
2
6
2
12
147
14
72
29
59
61
41
19
38
13
1
2
17
1,810
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaClassificationHead
import torch import torch.nn.functional as F from torch import nn class MegaClassificationHead(nn.Module): """Head for sentence-level classification tasks.""" def __init__(self, config): super().__init__() self.dense = nn.Linear(config.hidden_size, config.hidden_size) classifier_dropou...
class MegaClassificationHead(nn.Module): '''Head for sentence-level classification tasks.''' def __init__(self, config): pass def forward(self, features, **kwargs): pass
3
1
8
0
8
1
2
0.12
1
1
0
0
2
3
2
12
20
2
17
8
14
2
15
8
12
2
1
0
3
1,811
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaDropout
import torch.nn.functional as F from torch import nn class MegaDropout(nn.Module): """ A unified class for standard dropout functionality and featurewise dropout. The original fairseq Mega repo used 2 classes for these, which included some unnecessary handling of training logic and an unused `inplace`...
class MegaDropout(nn.Module): ''' A unified class for standard dropout functionality and featurewise dropout. The original fairseq Mega repo used 2 classes for these, which included some unnecessary handling of training logic and an unused `inplace` option. The original implementation used torch.nn.fun...
3
1
13
0
10
3
3
0.57
1
3
0
0
2
2
2
12
36
3
21
5
18
12
13
5
10
4
1
3
5
1,812
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaEmbeddings
import torch import torch.nn.functional as F from torch import nn from .configuration_mega import MegaConfig class MegaEmbeddings(nn.Module): """ Mega's basic implementation does not incorporate token type embeddings, so this is a stripped-down version of RoBERTa's embeddings which optionally includes toke...
class MegaEmbeddings(nn.Module): ''' Mega's basic implementation does not incorporate token type embeddings, so this is a stripped-down version of RoBERTa's embeddings which optionally includes token types ''' def __init__(self, config: MegaConfig): pass def forward(self, input_ids=No...
3
1
23
2
17
4
4
0.35
1
3
1
0
2
4
2
12
52
6
34
13
31
12
28
13
25
6
1
3
8
1,813
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaForCausalLM
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from torch import nn from ....modeling_outputs import BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutpu...
@add_start_docstrings('MEGA Model with a `language modeling` head on top for CLM fine-tuning.', MEGA_START_DOCSTRING) class MegaForCausalLM(MegaPreTrainedModel): def __init__(self, config: MegaConfig): pass @add_start_docstrings_to_model_forward(MEGA_INPUTS_DOCSTRING.format('batch_size, sequence_length...
8
1
25
4
14
7
3
0.47
1
7
3
0
6
4
6
136
158
29
88
37
65
41
50
22
43
7
3
1
17
1,814
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaForMaskedLM
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from torch import nn from ....modeling_outputs import BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutpu...
@add_start_docstrings('MEGA Model with a `language modeling` head on top.', MEGA_START_DOCSTRING) class MegaForMaskedLM(MegaPreTrainedModel): def __init__(self, config: MegaConfig): pass def get_output_embeddings(self): pass def set_output_embeddings(self, new_embeddings): pass ...
8
1
20
2
16
2
3
0.12
1
6
3
0
4
5
4
134
95
11
75
30
49
9
35
17
30
6
3
1
11
1,815
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaForMultipleChoice
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from torch import nn from ....modeling_outputs import BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutpu...
@add_start_docstrings('\n MEGA Model with a multiple choice classification head on top (a linear layer on top of the pooled output and a\n softmax) e.g. for RocStories/SWAG tasks.\n ', MEGA_START_DOCSTRING) class MegaForMultipleChoice(MegaPreTrainedModel): def __init__(self, config): pass @add...
6
1
34
4
27
4
6
0.12
1
5
2
0
2
3
2
132
76
9
60
29
41
7
27
18
24
10
3
1
11
1,816
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaForQuestionAnswering
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from torch import nn from ....modeling_outputs import BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutpu...
@add_start_docstrings('\n MEGA Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear\n layers on top of the hidden-states output to compute `span start logits` and `span end logits`).\n ', MEGA_START_DOCSTRING) class MegaForQuestionAnswering(MegaPreTrainedMod...
6
1
39
5
28
7
4
0.21
1
5
2
0
2
3
2
132
86
10
63
28
43
13
32
16
29
7
3
2
8
1,817
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaForSequenceClassification
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ....modeling_outputs import BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from ....utils impo...
@add_start_docstrings('\n MEGA Model transformer with a sequence classification/regression head on top (a linear layer on top of the pooled\n output) e.g. for GLUE tasks.\n ', MEGA_START_DOCSTRING) class MegaForSequenceClassification(MegaPreTrainedModel): def __init__(self, config): pass @add_...
6
1
37
4
30
4
7
0.1
1
7
3
0
2
4
2
132
82
8
67
24
48
7
33
13
30
12
3
3
13
1,818
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaForTokenClassification
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from torch import nn from ....modeling_outputs import BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutpu...
@add_start_docstrings('\n MEGA Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for\n Named-Entity-Recognition (NER) tasks.\n ', MEGA_START_DOCSTRING) class MegaForTokenClassification(MegaPreTrainedModel): def __init__(self, config): pass @...
6
1
30
4
24
3
4
0.09
1
5
2
0
2
4
2
132
68
9
54
25
35
5
23
14
20
5
3
1
7
1,819
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaGatedCrossAttention
from torch import nn import torch.nn.functional as F from ....cache_utils import Cache from .configuration_mega import MegaConfig import torch from ....activations import ACT2FN from typing import Optional, Union class MegaGatedCrossAttention(nn.Module): """ Gated Structured State Attention for use in encoder-...
class MegaGatedCrossAttention(nn.Module): ''' Gated Structured State Attention for use in encoder-decoder model. See Mega paper for more details. Only modifications from original implementation are variable names, removing the unnecessary `before_attn_fn` and `static_kv` arguments, and the stateful rep...
5
2
62
9
36
17
9
0.49
1
10
5
0
4
15
4
14
256
38
146
56
132
72
113
47
108
20
1
2
35
1,820
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaModel
from torch import nn from ....modeling_outputs import BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from ....utils import add_code_sample_docstrings, add_start_docs...
@add_start_docstrings('The bare MEGA Model transformer outputting raw hidden-states without any specific head on top.', MEGA_START_DOCSTRING) class MegaModel(MegaPreTrainedModel): ''' The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of cross-attention...
8
2
42
6
28
9
8
0.38
1
11
5
0
4
4
4
134
195
31
119
41
95
45
67
27
62
26
3
3
30
1,821
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaMovingAverageGatedAttention
from torch import nn import torch.nn.functional as F from ....cache_utils import Cache from .configuration_mega import MegaConfig import torch from ....activations import ACT2FN from typing import Optional, Union class MegaMovingAverageGatedAttention(nn.Module): """ Pure PyTorch implementation of Mega block; s...
class MegaMovingAverageGatedAttention(nn.Module): ''' Pure PyTorch implementation of Mega block; see https://huggingface.co/papers/2209.10655 and original fairseq implementation at https://github.com/facebookresearch/mega (copyright Meta Research, licensed under MIT License) Differences from original i...
5
4
81
11
45
25
9
0.6
1
11
6
0
4
16
4
14
334
49
179
59
166
107
137
51
132
20
1
3
37
1,822
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaMultiDimensionDampedEma
import math from torch import nn import torch.nn.functional as F from .configuration_mega import MegaConfig import torch from typing import Optional, Union class MegaMultiDimensionDampedEma(nn.Module): """ Mega's Exponential Moving Average layer, largely left unmodified from the original repo with the exceptio...
class MegaMultiDimensionDampedEma(nn.Module): ''' Mega's Exponential Moving Average layer, largely left unmodified from the original repo with the exception of variable names and moving away from the stateful representation of incremental decoding state. See "https://huggingface.co/papers/2209.10655" f...
10
2
21
2
13
6
3
0.51
1
7
1
0
9
13
9
19
207
27
119
62
103
61
105
56
95
6
1
2
25
1,823
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaNormalizedFeedForwardNetwork
from ....activations import ACT2FN from torch import nn from .configuration_mega import MegaConfig class MegaNormalizedFeedForwardNetwork(nn.Module): """ Normalized feed-forward network used in Mega blocks. Left as-is from original Mega repo aside from retrieving args from Hugging Face config """ ...
class MegaNormalizedFeedForwardNetwork(nn.Module): ''' Normalized feed-forward network used in Mega blocks. Left as-is from original Mega repo aside from retrieving args from Hugging Face config ''' def __init__(self, config: MegaConfig): pass def forward(self, inputs): pass
3
1
18
4
14
0
2
0.14
1
4
3
0
2
10
2
12
43
10
29
16
26
4
25
16
22
3
1
1
4
1,824
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaPooler
import torch import torch.nn.functional as F from torch import nn class MegaPooler(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) -> to...
class MegaPooler(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
1,825
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaPreTrainedModel
from torch import nn import torch.nn.functional as F from .configuration_mega import MegaConfig from ....modeling_utils import PreTrainedModel import torch class MegaPreTrainedModel(PreTrainedModel): """ An abstract class to handle weights initialization and a simple interface for downloading and loading pretr...
class MegaPreTrainedModel(PreTrainedModel): ''' An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models. ''' def _init_weights(self, module): '''Initialize the weights''' pass
2
2
43
0
37
6
15
0.24
1
8
6
7
1
0
1
130
54
2
42
8
40
10
34
8
32
15
2
3
15
1,826
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaRMSNorm
import torch.nn.functional as F from torch import nn import torch class MegaRMSNorm(nn.Module): """ RMSNorm used in Mega implementation. Differs from T5's RMSNorm by applying the weight prior to taking the square root (as opposed to after in T5) """ def __init__(self, number_features, eps=1e-06, a...
class MegaRMSNorm(nn.Module): ''' RMSNorm used in Mega implementation. Differs from T5's RMSNorm by applying the weight prior to taking the square root (as opposed to after in T5) ''' def __init__(self, number_features, eps=1e-06, affine=True): pass def forward(self, input): p...
4
1
6
0
6
0
2
0.22
1
2
0
0
3
4
3
13
26
4
18
9
14
4
17
9
13
2
1
1
5
1,827
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaRotaryRelativePositionalBias
import math from torch import nn import torch.nn.functional as F from .configuration_mega import MegaConfig import torch class MegaRotaryRelativePositionalBias(nn.Module): """ Rotary relative bias for positional information; similar in concept to RoPE (i.e. RoFormer) but taken from the Mega repo due to dif...
class MegaRotaryRelativePositionalBias(nn.Module): ''' Rotary relative bias for positional information; similar in concept to RoPE (i.e. RoFormer) but taken from the Mega repo due to differences in implementation. When initialized, produces a positional bias which ranges from position 0 to config.max_p...
6
1
10
0
9
1
2
0.22
1
6
1
0
3
7
4
14
51
6
37
21
31
8
34
20
29
3
1
1
7
1,828
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaScaleNorm
import torch import torch.nn.functional as F from torch import nn class MegaScaleNorm(nn.Module): """ Scale normalization introduced in MEGA which is similar to RMSNorm, but uses a single parameter for scalar multiplication instead of a vector, and applies over a specified dimension """ def __init...
class MegaScaleNorm(nn.Module): ''' Scale normalization introduced in MEGA which is similar to RMSNorm, but uses a single parameter for scalar multiplication instead of a vector, and applies over a specified dimension ''' def __init__(self, dim, eps=1e-06, affine=True): pass def forwa...
3
1
8
1
8
0
2
0.25
1
2
0
0
2
4
2
12
23
3
16
9
13
4
15
9
12
2
1
1
4
1,829
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaSequenceNorm
from torch import nn class MegaSequenceNorm(nn.Module): """ A wrapper class for various layer normalization options used in Mega. Used to handle differences in expectations on input axis locations for different normalization methods. """ def __init__(self, norm_type, embedding_dim, eps=1e-05, affi...
class MegaSequenceNorm(nn.Module): ''' A wrapper class for various layer normalization options used in Mega. Used to handle differences in expectations on input axis locations for different normalization methods. ''' def __init__(self, norm_type, embedding_dim, eps=1e-05, affine=True, export=False...
3
1
12
0
12
0
5
0.17
1
4
2
0
2
1
2
12
30
2
24
4
21
4
18
4
15
6
1
2
9
1,830
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mega/modeling_mega.py
transformers.models.deprecated.mega.modeling_mega.MegaSimpleRelativePositionalBias
import torch import torch.nn.functional as F from torch import nn from .configuration_mega import MegaConfig class MegaSimpleRelativePositionalBias(nn.Module): """ Simple relative positional embeddings copied from the Mega repo; renamed variables for better readability """ def __init__(self, config: M...
class MegaSimpleRelativePositionalBias(nn.Module): ''' Simple relative positional embeddings copied from the Mega repo; renamed variables for better readability ''' def __init__(self, config: MegaConfig): pass def forward(self, seq_len): pass
3
1
11
1
9
2
2
0.39
1
4
1
0
2
3
2
12
28
3
18
10
15
7
18
10
15
2
1
1
4
1,831
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mmbt/configuration_mmbt.py
transformers.models.deprecated.mmbt.configuration_mmbt.MMBTConfig
class MMBTConfig: """ This is the configuration class to store the configuration of a [`MMBTModel`]. It is used to instantiate a MMBT model according to the specified arguments, defining the model architecture. Args: config ([`PreTrainedConfig`]): Config of the underlying Transforme...
class MMBTConfig: ''' This is the configuration class to store the configuration of a [`MMBTModel`]. It is used to instantiate a MMBT model according to the specified arguments, defining the model architecture. Args: config ([`PreTrainedConfig`]): Config of the underlying Transformer...
2
1
5
0
5
0
2
1.83
0
0
0
0
1
3
1
1
19
2
6
5
4
11
6
5
4
2
0
1
2
1,832
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mmbt/modeling_mmbt.py
transformers.models.deprecated.mmbt.modeling_mmbt.MMBTForClassification
from torch.nn import CrossEntropyLoss, MSELoss from torch import nn from ....modeling_outputs import BaseModelOutputWithPooling, SequenceClassifierOutput from ....utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings @add_start_docstrings('\n MMBT Model with a ...
@add_start_docstrings('\n MMBT Model with a sequence classification/regression head on top (a linear layer on top of the pooled output)\n ', MMBT_START_DOCSTRING, MMBT_INPUTS_DOCSTRING) class MMBTForClassification(nn.Module): ''' **labels**: (*optional*) `torch.LongTensor` of shape `(batch_size,)`: ...
4
1
33
4
29
1
4
0.45
1
3
2
0
2
4
2
12
96
12
58
28
40
26
24
13
21
6
1
2
7
1,833
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mmbt/modeling_mmbt.py
transformers.models.deprecated.mmbt.modeling_mmbt.MMBTModel
from ....modeling_utils import ModuleUtilsMixin from ....modeling_outputs import BaseModelOutputWithPooling, SequenceClassifierOutput from torch import nn from ....utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings import torch @add_start_docstrings('The bare M...
@add_start_docstrings('The bare MMBT Model outputting raw hidden-states without any specific head on top.', MMBT_START_DOCSTRING) class MMBTModel(nn.Module, ModuleUtilsMixin): def __init__(self, config, transformer, encoder): pass @add_start_docstrings_to_model_forward(MMBT_INPUTS_DOCSTRING) @repla...
8
1
29
4
23
2
4
0.09
2
4
2
0
4
3
4
28
123
19
95
39
70
9
42
20
37
12
1
1
15
1,834
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mmbt/modeling_mmbt.py
transformers.models.deprecated.mmbt.modeling_mmbt.ModalEmbeddings
import torch from torch import nn class ModalEmbeddings(nn.Module): """Generic Modal Embeddings which takes in an encoder, and a transformer embedding.""" def __init__(self, config, encoder, embeddings): super().__init__() self.config = config self.encoder = encoder self.proj_e...
class ModalEmbeddings(nn.Module): '''Generic Modal Embeddings which takes in an encoder, and a transformer embedding.''' def __init__(self, config, encoder, embeddings): pass def forward(self, input_modal, start_token=None, end_token=None, position_ids=None, token_type_ids=None): pass
3
1
20
3
17
0
3
0.03
1
1
0
0
2
8
2
12
43
7
35
18
32
1
33
18
30
5
1
1
6
1,835
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/configuration_nat.py
transformers.models.deprecated.nat.configuration_nat.NatConfig
from ....configuration_utils import PretrainedConfig from ....utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices class NatConfig(BackboneConfigMixin, PretrainedConfig): """ This is the configuration class to store the configuration of a [`NatModel`]. It is used to insta...
class NatConfig(BackboneConfigMixin, PretrainedConfig): ''' This is the configuration class to store the configuration of a [`NatModel`]. It is used to instantiate a Nat model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yie...
2
1
46
1
43
2
1
1.24
2
3
0
0
1
20
1
38
121
11
49
43
27
61
24
23
22
1
2
0
1
1,836
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatBackbone
from ....utils import ModelOutput, OptionalDependencyNotAvailable, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, is_natten_available, logging, replace_return_docstrings, requires_backends import torch from torch import nn from typing import Optional, Union from ....utils.backb...
@add_start_docstrings('NAT backbone, to be used with frameworks like DETR and MaskFormer.', NAT_START_DOCSTRING) class NatBackbone(NatPreTrainedModel, BackboneMixin): def __init__(self, config): pass def get_input_embeddings(self): pass @add_start_docstrings_to_model_forward(NAT_INPUTS_DOC...
7
1
32
6
18
8
4
0.4
2
9
3
0
3
4
3
145
100
19
58
24
46
23
38
17
34
9
3
2
12
1,837
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatDownsampler
import torch from torch import nn class NatDownsampler(nn.Module): """ Convolutional Downsampling Layer. Args: dim (`int`): Number of input channels. norm_layer (`nn.Module`, *optional*, defaults to `nn.LayerNorm`): Normalization layer class. """ def __init...
class NatDownsampler(nn.Module): ''' Convolutional Downsampling Layer. Args: dim (`int`): Number of input channels. norm_layer (`nn.Module`, *optional*, defaults to `nn.LayerNorm`): Normalization layer class. ''' def __init__(self, dim: int, norm...
3
1
5
0
5
0
1
0.8
1
3
0
0
2
3
2
12
21
3
10
6
7
8
10
6
7
1
1
0
2
1,838
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatDropPath
from typing import Optional, Union from torch import nn import torch class NatDropPath(nn.Module): """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).""" def __init__(self, drop_prob: Optional[float]=None) -> None: super().__init__() self.drop_prob = dro...
class NatDropPath(nn.Module): '''Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).''' def __init__(self, drop_prob: Optional[float]=None) -> None: pass def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: pass def extra_repr(self) -> ...
4
1
2
0
2
0
1
0.13
1
4
0
0
3
1
3
13
12
3
8
5
4
1
8
5
4
1
1
0
3
1,839
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatEmbeddings
from torch import nn from typing import Optional, Union import torch class NatEmbeddings(nn.Module): """ Construct the patch and position embeddings. """ def __init__(self, config): super().__init__() self.patch_embeddings = NatPatchEmbeddings(config) self.norm = nn.LayerNorm(c...
class NatEmbeddings(nn.Module): ''' Construct the patch and position embeddings. ''' def __init__(self, config): pass def forward(self, pixel_values: Optional[torch.FloatTensor]) -> tuple[torch.Tensor]: pass
3
1
7
2
5
0
1
0.27
1
3
1
0
2
3
2
12
20
6
11
7
8
3
11
7
8
1
1
0
2
1,840
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatEncoder
from torch import nn import torch from typing import Optional, Union class NatEncoder(nn.Module): def __init__(self, config): super().__init__() self.num_levels = len(config.depths) self.config = config dpr = [x.item() for x in torch.linspace(0, config.drop_path_rate, sum(config.de...
class NatEncoder(nn.Module): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor, output_attentions: Optional[bool]=False, output_hidden_states: Optional[bool]=False, output_hidden_states_before_downsampling: Optional[bool]=False, return_dict: Optional[bool]=True) -> Union[...
3
0
33
4
28
2
6
0.05
1
10
3
0
2
3
2
12
67
8
56
21
46
3
31
14
28
10
1
2
12
1,841
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatEncoderOutput
import torch from ....utils import ModelOutput, OptionalDependencyNotAvailable, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, is_natten_available, logging, replace_return_docstrings, requires_backends from typing import Optional, Union from dataclasses import dataclass @datac...
@dataclass class NatEncoderOutput(ModelOutput): ''' Nat encoder's outputs, with potential hidden states and attentions. Args: last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`): Sequence of hidden-states at the output of the last layer of the mo...
2
1
0
0
0
0
0
4
1
0
0
0
0
0
0
0
30
5
5
5
4
20
5
5
4
0
1
0
0
1,842
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatForImageClassification
from ....utils import ModelOutput, OptionalDependencyNotAvailable, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, is_natten_available, logging, replace_return_docstrings, requires_backends import torch from torch import nn from typing import Optional, Union @add_start_docstrin...
@add_start_docstrings('\n Nat Model transformer with an image classification head on top (a linear layer on top of the final hidden state of\n the [CLS] token) e.g. for ImageNet.\n ', NAT_START_DOCSTRING) class NatForImageClassification(NatPreTrainedModel): def __init__(self, config): pass @ad...
6
1
38
6
29
4
7
0.12
1
5
2
0
2
3
2
132
85
12
65
20
48
8
33
12
30
12
3
3
14
1,843
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatImageClassifierOutput
from dataclasses import dataclass import torch from ....utils import ModelOutput, OptionalDependencyNotAvailable, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, is_natten_available, logging, replace_return_docstrings, requires_backends from typing import Optional, Union @datac...
@dataclass class NatImageClassifierOutput(ModelOutput): ''' Nat outputs for image classification. Args: loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided): Classification (or regression if config.num_labels==1) loss. logits (`torch.FloatTen...
2
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
1,844
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatIntermediate
import torch from torch import nn from ....activations import ACT2FN class NatIntermediate(nn.Module): def __init__(self, config, dim): super().__init__() self.dense = nn.Linear(dim, int(config.mlp_ratio * dim)) if isinstance(config.hidden_act, str): self.intermediate_act_fn = ...
class NatIntermediate(nn.Module): def __init__(self, config, dim): pass def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: pass
3
0
6
0
6
0
2
0
1
4
0
0
2
2
2
12
13
1
12
5
9
0
11
5
8
2
1
1
3
1,845
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatLayer
from typing import Optional, Union import torch from torch import nn class NatLayer(nn.Module): def __init__(self, config, dim, num_heads, drop_path_rate=0.0): super().__init__() self.chunk_size_feed_forward = config.chunk_size_feed_forward self.kernel_size = config.kernel_size sel...
class NatLayer(nn.Module): def __init__(self, config, dim, num_heads, drop_path_rate=0.0): pass def maybe_pad(self, hidden_states, height, width): pass def forward(self, hidden_states: torch.Tensor, output_attentions: Optional[bool]=False) -> tuple[torch.Tensor, torch.Tensor]: pa...
4
0
21
4
17
0
3
0.02
1
7
4
0
3
9
3
13
65
13
51
31
43
1
43
27
39
5
1
1
10
1,846
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatModel
from torch import nn from ....utils import ModelOutput, OptionalDependencyNotAvailable, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, is_natten_available, logging, replace_return_docstrings, requires_backends import torch from typing import Optional, Union @add_start_docstrin...
@add_start_docstrings('The bare Nat Model transformer outputting raw hidden-states without any specific head on top.', NAT_START_DOCSTRING) class NatModel(NatPreTrainedModel): def __init__(self, config, add_pooling_layer=True): pass def get_input_embeddings(self): pass def _prune_heads(se...
8
1
18
3
13
1
3
0.08
1
7
3
0
4
7
4
134
83
16
62
25
43
5
35
18
30
7
3
1
12
1,847
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatModelOutput
from ....utils import ModelOutput, OptionalDependencyNotAvailable, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, is_natten_available, logging, replace_return_docstrings, requires_backends import torch from dataclasses import dataclass from typing import Optional, Union @datac...
@dataclass class NatModelOutput(ModelOutput): ''' Nat model's outputs that also contains a pooling of the last hidden states. Args: last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`): Sequence of hidden-states at the output of the last layer of ...
2
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
1,848
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatOutput
import torch from torch import nn class NatOutput(nn.Module): def __init__(self, config, dim): super().__init__() self.dense = nn.Linear(int(config.mlp_ratio * dim), dim) self.dropout = nn.Dropout(config.hidden_dropout_prob) def forward(self, hidden_states: torch.Tensor) -> torch.Tens...
class NatOutput(nn.Module): def __init__(self, config, dim): pass def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: pass
3
0
4
0
4
0
1
0
1
3
0
0
2
2
2
12
10
1
9
5
6
0
9
5
6
1
1
0
2
1,849
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatPatchEmbeddings
from torch import nn from typing import Optional, Union import torch class NatPatchEmbeddings(nn.Module): """ This class turns `pixel_values` of shape `(batch_size, num_channels, height, width)` into the initial `hidden_states` (patch embeddings) of shape `(batch_size, height, width, hidden_size)` to be co...
class NatPatchEmbeddings(nn.Module): ''' This class turns `pixel_values` of shape `(batch_size, num_channels, height, width)` into the initial `hidden_states` (patch embeddings) of shape `(batch_size, height, width, hidden_size)` to be consumed by a Transformer. ''' def __init__(self, config):...
3
1
13
2
11
1
2
0.26
1
3
0
0
2
2
2
12
34
5
23
9
20
6
17
9
14
2
1
1
4
1,850
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatPreTrainedModel
from torch import nn from ....modeling_utils import PreTrainedModel from .configuration_nat import NatConfig class NatPreTrainedModel(PreTrainedModel): """ An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models. """ config: NatConfig ...
class NatPreTrainedModel(PreTrainedModel): ''' An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models. ''' def _init_weights(self, module): '''Initialize the weights''' pass
2
2
11
0
8
3
4
0.58
1
0
0
3
1
0
1
130
21
2
12
5
10
7
11
5
9
4
2
2
4
1,851
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NatStage
from torch import nn import torch from typing import Optional, Union class NatStage(nn.Module): def __init__(self, config, dim, depth, num_heads, drop_path_rate, downsample): super().__init__() self.config = config self.dim = dim self.layers = nn.ModuleList([NatLayer(config=config,...
class NatStage(nn.Module): def __init__(self, config, dim, depth, num_heads, drop_path_rate, downsample): pass def forward(self, hidden_states: torch.Tensor, output_attentions: Optional[bool]=False) -> tuple[torch.Tensor]: pass
3
0
21
3
18
1
3
0.03
1
6
1
0
2
5
2
12
44
6
37
17
30
1
22
13
19
4
1
1
6
1,852
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NeighborhoodAttention
import torch import math from typing import Optional, Union from torch import nn class NeighborhoodAttention(nn.Module): def __init__(self, config, dim, num_heads, kernel_size): super().__init__() if dim % num_heads != 0: raise ValueError(f'The hidden size ({dim}) is not a multiple of ...
class NeighborhoodAttention(nn.Module): def __init__(self, config, dim, num_heads, kernel_size): pass def transpose_for_scores(self, x): pass def forward(self, hidden_states: torch.Tensor, output_attentions: Optional[bool]=False) -> tuple[torch.Tensor]: pass
4
0
19
4
12
3
2
0.21
1
5
0
0
3
9
3
13
59
13
38
26
30
8
32
22
28
2
1
1
5
1,853
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nat/modeling_nat.py
transformers.models.deprecated.nat.modeling_nat.NeighborhoodAttentionModule
from ....pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer from typing import Optional, Union import torch from torch import nn class NeighborhoodAttentionModule(nn.Module): def __init__(self, config, dim, num_heads, kernel_size): super().__init__() self.self = Neighborhood...
class NeighborhoodAttentionModule(nn.Module): def __init__(self, config, dim, num_heads, kernel_size): pass def prune_heads(self, heads): pass def forward(self, hidden_states: torch.Tensor, output_attentions: Optional[bool]=False) -> tuple[torch.Tensor]: pass
4
0
10
1
9
1
1
0.11
1
6
2
0
3
3
3
13
34
4
28
15
20
3
22
11
18
2
1
1
4
1,854
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/configuration_nezha.py
transformers.models.deprecated.nezha.configuration_nezha.NezhaConfig
from .... import PretrainedConfig class NezhaConfig(PretrainedConfig): """ This is the configuration class to store the configuration of an [`NezhaModel`]. It is used to instantiate an Nezha model according to the specified arguments, defining the model architecture. Instantiating a configuration with the ...
class NezhaConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of an [`NezhaModel`]. It is used to instantiate an Nezha model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar ...
2
1
39
1
38
0
1
1.2
1
1
0
0
1
15
1
33
99
11
40
39
17
48
19
18
17
1
2
0
1
1,855
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaAttention
from ....cache_utils import Cache from typing import Optional, Union from ....utils.deprecation import deprecate_kwarg from ....pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer from torch import nn import torch class NezhaAttention(nn.Module): def __init__(self,...
class NezhaAttention(nn.Module): def __init__(self, config): pass def prune_heads(self, heads): 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.FloatTensor]=None, head_mas...
5
0
15
1
13
1
1
0.07
1
6
2
0
3
3
3
13
47
4
41
20
28
3
22
11
18
2
1
1
4
1,856
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaEmbeddings
from torch import nn import torch from typing import Optional, Union class NezhaEmbeddings(nn.Module): """Construct the embeddings from word and token_type embeddings.""" def __init__(self, config): super().__init__() self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, p...
class NezhaEmbeddings(nn.Module): '''Construct the embeddings from word and token_type embeddings.''' def __init__(self, config): pass def forward(self, input_ids: Optional[torch.LongTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, inputs_embeds: Optional[torch.FloatTensor]=None) ->...
3
1
23
3
17
3
3
0.17
1
2
0
0
2
4
2
12
49
8
35
18
27
6
26
13
23
5
1
2
6
1,857
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaEncoder
from ....cache_utils import Cache from typing import Optional, Union from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, NextSentencePredictorOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, T...
class NezhaEncoder(nn.Module): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, encoder_hidden_states: Optional[torch.FloatTensor]=None, encoder_attention_mask: Optional[torch...
3
0
45
4
41
0
9
0
1
8
2
0
2
3
2
12
91
8
83
26
68
0
35
14
32
17
1
3
18
1,858
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaForMaskedLM
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, NextSentencePredictorOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, Toke...
@add_start_docstrings('Nezha Model with a `language modeling` head on top.', NEZHA_START_DOCSTRING) class NezhaForMaskedLM(NezhaPreTrainedModel): def __init__(self, config): pass def get_output_embeddings(self): pass def set_output_embeddings(self, new_embeddings): pass @add_s...
9
1
18
2
14
2
2
0.12
1
7
3
0
5
2
5
135
101
17
76
32
51
9
36
18
30
5
3
1
11
1,859
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaForMultipleChoice
from typing import Optional, Union from ....utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ....modeling_outputs import BaseModelOutputWithPastAndC...
@add_start_docstrings('\n Nezha Model with a multiple choice classification head on top (a linear layer on top of the pooled output and a\n softmax) e.g. for RocStories/SWAG tasks.\n ', NEZHA_START_DOCSTRING) class NezhaForMultipleChoice(NezhaPreTrainedModel): def __init__(self, config): pass ...
6
1
38
4
31
4
6
0.1
1
5
2
0
2
3
2
132
83
8
68
27
48
7
31
15
28
10
3
1
12
1,860
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaForNextSentencePrediction
from typing import Optional, Union from ....utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss import warnings from ....modeling_outputs import BaseModelOu...
@add_start_docstrings('Nezha Model with a `next sentence prediction (classification)` head on top.', NEZHA_START_DOCSTRING) class NezhaForNextSentencePrediction(NezhaPreTrainedModel): def __init__(self, config): pass @add_start_docstrings_to_model_forward(NEZHA_INPUTS_DOCSTRING.format('batch_size, sequ...
6
1
45
9
26
11
4
0.41
1
7
3
0
2
2
2
132
94
18
54
24
37
22
22
11
19
6
3
1
7
1,861
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaForPreTraining
from ....utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss import torch from typing import Optional, Union @add_start_docstrings('\n Nezha Model with ...
@add_start_docstrings('\n Nezha Model with two heads on top as done during the pretraining: a `masked language modeling` head and a `next\n sentence prediction (classification)` head.\n ', NEZHA_START_DOCSTRING) class NezhaForPreTraining(NezhaPreTrainedModel): def __init__(self, config): pass ...
8
1
23
4
13
7
2
0.46
1
6
3
0
4
2
4
134
100
18
56
29
37
26
27
16
22
5
3
1
8
1,862
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaForPreTrainingOutput
from typing import Optional, Union from ....utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings from dataclasses import dataclass import torch @dataclass class NezhaForPreTrainingOutput(ModelOutput): """ Output ty...
@dataclass class NezhaForPreTrainingOutput(ModelOutput): ''' Output type of [`NezhaForPreTraining`]. Args: loss (*optional*, returned when `labels` is provided, `torch.FloatTensor` of shape `(1,)`): Total loss as the sum of the masked language modeling loss and the next sequence predicti...
2
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
1,863
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaForQuestionAnswering
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, NextSentencePredictorOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, Toke...
@add_start_docstrings('\n Nezha Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear\n layers on top of the hidden-states output to compute `span start logits` and `span end logits`).\n ', NEZHA_START_DOCSTRING) class NezhaForQuestionAnswering(NezhaPreTraine...
6
1
40
5
29
7
4
0.2
1
5
2
0
2
3
2
132
88
10
65
29
44
13
32
16
29
7
3
2
8
1,864
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaForSequenceClassification
from typing import Optional, Union from ....utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ....modeling_outputs import BaseModelOutputWithPastAndC...
@add_start_docstrings('\n Nezha Model transformer with a sequence classification/regression head on top (a linear layer on top of the pooled\n output) e.g. for GLUE tasks.\n ', NEZHA_START_DOCSTRING) class NezhaForSequenceClassification(NezhaPreTrainedModel): def __init__(self, config): pass @...
6
1
41
4
34
4
7
0.09
1
6
2
0
2
5
2
132
90
9
74
27
54
7
36
15
33
12
3
3
14
1,865
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaForTokenClassification
import torch from typing import Optional, Union from ....utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ....modeling_outputs import BaseModelOutpu...
@add_start_docstrings('\n Nezha Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for\n Named-Entity-Recognition (NER) tasks.\n ', NEZHA_START_DOCSTRING) class NezhaForTokenClassification(NezhaPreTrainedModel): def __init__(self, config): pass ...
6
1
31
4
25
3
4
0.09
1
5
2
0
2
4
2
132
70
9
56
26
36
5
23
14
20
5
3
1
7
1,866
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaIntermediate
from ....activations import ACT2FN from torch import nn import torch class NezhaIntermediate(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.intermediate_...
class NezhaIntermediate(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
1,867
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaLMPredictionHead
from torch import nn import torch class NezhaLMPredictionHead(nn.Module): def __init__(self, config): super().__init__() self.transform = NezhaPredictionHeadTransform(config) self.decoder = nn.Linear(config.hidden_size, config.vocab_size, bias=False) self.bias = nn.Parameter(torch....
class NezhaLMPredictionHead(nn.Module): def __init__(self, config): pass def _tie_weights(self): pass def forward(self, hidden_states): pass
4
0
6
1
4
1
1
0.23
1
2
1
0
3
3
3
13
21
5
13
7
9
3
13
7
9
1
1
0
3
1,868
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaLayer
from ....utils.deprecation import deprecate_kwarg from ....pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer from ....modeling_layers import GradientCheckpointingLayer import torch from ....cache_utils import Cache from typing import Optional, Union class NezhaLayer(G...
class NezhaLayer(GradientCheckpointingLayer): def __init__(self, config): 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.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None...
5
0
27
2
23
2
4
0.1
1
7
3
0
3
8
3
13
84
9
70
32
57
7
41
23
37
7
1
2
11
1,869
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaModel
from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, NextSentencePredictorOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput import torch from ....utils import ModelOutput, ...
@add_start_docstrings('The bare Nezha Model transformer outputting raw hidden-states without any specific head on top.', NEZHA_START_DOCSTRING) class NezhaModel(NezhaPreTrainedModel): ''' The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of cross-atten...
9
3
30
3
20
7
5
0.4
1
8
4
0
5
4
5
135
171
24
105
40
79
42
55
25
49
18
3
2
24
1,870
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaOnlyMLMHead
from torch import nn import torch class NezhaOnlyMLMHead(nn.Module): def __init__(self, config): super().__init__() self.predictions = NezhaLMPredictionHead(config) def forward(self, sequence_output: torch.Tensor) -> torch.Tensor: prediction_scores = self.predictions(sequence_output) ...
class NezhaOnlyMLMHead(nn.Module): def __init__(self, config): pass def forward(self, sequence_output: torch.Tensor) -> torch.Tensor: pass
3
0
3
0
3
0
1
0
1
3
1
0
2
1
2
12
8
1
7
5
4
0
7
5
4
1
1
0
2
1,871
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaOnlyNSPHead
from torch import nn class NezhaOnlyNSPHead(nn.Module): def __init__(self, config): super().__init__() self.seq_relationship = nn.Linear(config.hidden_size, 2) def forward(self, pooled_output): seq_relationship_score = self.seq_relationship(pooled_output) return seq_relationsh...
class NezhaOnlyNSPHead(nn.Module): def __init__(self, config): pass def forward(self, pooled_output): pass
3
0
3
0
3
0
1
0
1
1
0
0
2
1
2
12
8
1
7
5
4
0
7
5
4
1
1
0
2
1,872
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaOutput
from torch import nn import torch class NezhaOutput(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 NezhaOutput(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
1,873
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaPooler
from torch import nn import torch class NezhaPooler(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 NezhaPooler(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
1,874
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaPreTrainedModel
from torch import nn from ....modeling_utils import PreTrainedModel from .configuration_nezha import NezhaConfig class NezhaPreTrainedModel(PreTrainedModel): """ An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models. """ config: Nezh...
class NezhaPreTrainedModel(PreTrainedModel): ''' An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models. ''' def _init_weights(self, module): '''Initialize the weights''' pass
2
2
15
0
12
3
6
0.41
1
0
0
8
1
0
1
130
26
2
17
6
15
7
15
6
13
6
2
2
6
1,875
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaPreTrainingHeads
from torch import nn class NezhaPreTrainingHeads(nn.Module): def __init__(self, config): super().__init__() self.predictions = NezhaLMPredictionHead(config) self.seq_relationship = nn.Linear(config.hidden_size, 2) def forward(self, sequence_output, pooled_output): prediction_s...
class NezhaPreTrainingHeads(nn.Module): def __init__(self, config): 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
1,876
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaPredictionHeadTransform
from torch import nn from ....activations import ACT2FN import torch class NezhaPredictionHeadTransform(nn.Module): def __init__(self, config): super().__init__() self.dense = nn.Linear(config.hidden_size, config.hidden_size) if isinstance(config.hidden_act, str): self.transfor...
class NezhaPredictionHeadTransform(nn.Module): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: pass
3
0
7
0
7
0
2
0
1
3
0
0
2
3
2
12
15
1
14
6
11
0
13
6
10
2
1
1
3
1,877
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaRelativePositionsEncoding
from torch import nn import math import torch class NezhaRelativePositionsEncoding(nn.Module): """Implement the Functional Relative Position Encoding""" def __init__(self, length, depth, max_relative_position=127): super().__init__() vocab_size = max_relative_position * 2 + 1 range_vec...
class NezhaRelativePositionsEncoding(nn.Module): '''Implement the Functional Relative Position Encoding''' def __init__(self, length, depth, max_relative_position=127): pass def forward(self, length): pass
3
1
13
1
12
0
1
0.04
1
2
0
0
2
0
2
12
30
4
25
16
22
1
23
16
20
1
1
0
2
1,878
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaSelfAttention
from torch import nn import math import torch from ....cache_utils import Cache from typing import Optional, Union from ....utils.deprecation import deprecate_kwarg class NezhaSelfAttention(nn.Module): def __init__(self, config): super().__init__() if config.hidden_size % config.num_attention_head...
class NezhaSelfAttention(nn.Module): def __init__(self, config): pass def transpose_for_scores(self, x: torch.Tensor) -> torch.Tensor: pass @deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58') def forward(self, hidden_states: torch.Tensor, attention_mask: Opt...
5
0
43
6
31
6
4
0.18
1
6
1
0
3
9
3
13
133
21
95
46
82
17
68
37
64
9
1
1
12
1,879
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/nezha/modeling_nezha.py
transformers.models.deprecated.nezha.modeling_nezha.NezhaSelfOutput
import torch from torch import nn class NezhaSelfOutput(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(c...
class NezhaSelfOutput(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
1,880
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/configuration_open_llama.py
transformers.models.deprecated.open_llama.configuration_open_llama.OpenLlamaConfig
from ....configuration_utils import PretrainedConfig class OpenLlamaConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`OpenLlamaModel`]. It is used to instantiate an Open-Llama model according to the specified arguments, defining the model architecture. Instanti...
class OpenLlamaConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`OpenLlamaModel`]. It is used to instantiate an Open-Llama model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yiel...
3
2
36
1
34
2
3
0.81
1
4
0
0
2
17
2
34
138
13
69
47
42
56
33
23
30
5
2
1
6
1,881
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaAttention
from .configuration_open_llama import OpenLlamaConfig import torch from torch import nn from ....cache_utils import Cache import math from typing import Optional, Union from ....utils.deprecation import deprecate_kwarg class OpenLlamaAttention(nn.Module): """Multi-headed attention from 'Attention Is All You Need' ...
class OpenLlamaAttention(nn.Module): '''Multi-headed attention from 'Attention Is All You Need' paper''' def __init__(self, config: OpenLlamaConfig): pass def _init_rope(self): pass def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int): pass @deprecate_kwarg('pas...
6
1
31
4
27
1
4
0.04
1
9
4
0
4
12
4
14
129
18
107
35
94
4
66
27
61
10
1
3
17
1,882
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaDecoderLayer
from ....cache_utils import Cache from typing import Optional, Union from .configuration_open_llama import OpenLlamaConfig import torch from ....modeling_layers import GradientCheckpointingLayer from ....utils.deprecation import deprecate_kwarg class OpenLlamaDecoderLayer(GradientCheckpointingLayer): def __init__...
class OpenLlamaDecoderLayer(GradientCheckpointingLayer): def __init__(self, config: OpenLlamaConfig): 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]=None, position_ids: Option...
4
1
33
4
21
8
2
0.35
1
7
4
0
2
5
2
12
67
9
43
19
32
15
23
11
20
3
1
1
4
1,883
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaDynamicNTKScalingRotaryEmbedding
import torch class OpenLlamaDynamicNTKScalingRotaryEmbedding(OpenLlamaRotaryEmbedding): """OpenLlamaRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla""" def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0): ...
class OpenLlamaDynamicNTKScalingRotaryEmbedding(OpenLlamaRotaryEmbedding): '''OpenLlamaRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla''' def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0): pass ...
3
1
10
2
8
1
2
0.12
1
1
0
0
2
3
2
15
24
5
17
10
14
2
15
10
12
2
2
1
3
1,884
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaForCausalLM
from torch import nn from typing import Optional, Union from ....cache_utils import Cache from ....utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings from ....modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPa...
class OpenLlamaForCausalLM(OpenLlamaPreTrainedModel): def __init__(self, config): pass @add_start_docstrings_to_model_forward(OPEN_LLAMA_INPUTS_DOCSTRING) @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC) def forward(self, input_ids: Optional[torch.Lo...
8
1
16
2
11
3
2
0.25
1
6
2
0
9
2
10
140
172
27
116
43
88
29
66
27
55
8
3
2
24
1,885
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaForSequenceClassification
from typing import Optional, Union from ....cache_utils import Cache import torch from ....modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ....utils import add_start_docstrings, add_start_doc...
null
5
1
25
2
21
2
5
0.09
1
7
2
0
4
3
4
134
106
11
87
30
69
8
50
17
45
16
3
3
19
1,886
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaLinearScalingRotaryEmbedding
import torch class OpenLlamaLinearScalingRotaryEmbedding(OpenLlamaRotaryEmbedding): """OpenLlamaRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev""" def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0): self.scaling_fac...
class OpenLlamaLinearScalingRotaryEmbedding(OpenLlamaRotaryEmbedding): '''OpenLlamaRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev''' def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0): pass def _set_cos_sin_ca...
3
1
7
1
6
1
1
0.17
1
1
0
0
2
2
2
15
17
3
12
8
9
2
12
8
9
1
2
0
2
1,887
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaMLP
from torch import nn from ....activations import ACT2FN class OpenLlamaMLP(nn.Module): def __init__(self, hidden_size: int, intermediate_size: int, hidden_act: str, dropout_prob: float): super().__init__() self.gate_proj = nn.Linear(hidden_size, intermediate_size, bias=False) self.down_pro...
class OpenLlamaMLP(nn.Module): def __init__(self, hidden_size: int, intermediate_size: int, hidden_act: str, dropout_prob: float): pass def forward(self, x): pass
3
0
8
0
8
0
1
0
1
4
0
0
2
5
2
12
18
1
17
15
8
0
11
9
8
1
1
0
2
1,888
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaModel
from ....modeling_attn_mask_utils import _prepare_4d_causal_attention_mask from ....modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast from torch import nn from ....cache_utils import Cache from typing import Optional, Union from .configuration_open_llama import Op...
@add_start_docstrings('The bare Open-Llama Model outputting raw hidden-states without any specific head on top.', OPEN_LLAMA_START_DOCSTRING) class OpenLlamaModel(OpenLlamaPreTrainedModel): ''' Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`OpenLlamaDecoderLayer`] Arg...
5
1
36
5
30
1
9
0.08
1
11
4
0
4
7
4
134
156
26
120
38
103
10
72
26
67
30
3
2
34
1,889
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaPreTrainedModel
from torch import nn from ....utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings from ....modeling_utils import PreTrainedModel import torch from .configuration_open_llama import OpenLlamaConfig @add_start_docstrings('The bare Open-Llama Model outputting raw hi...
@add_start_docstrings('The bare Open-Llama Model outputting raw hidden-states without any specific head on top.', OPEN_LLAMA_START_DOCSTRING) class OpenLlamaPreTrainedModel(PreTrainedModel): def _init_weights(self, module): pass
3
0
13
0
13
0
6
0
1
0
0
3
1
0
1
130
19
1
18
7
16
0
16
7
14
6
2
2
6
1,890
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaRMSNorm
import torch from torch import nn class OpenLlamaRMSNorm(nn.Module): def __init__(self, hidden_size, eps=1e-06): """ OpenLlamaRMSNorm is equivalent to T5LayerNorm """ super().__init__() self.weight = nn.Parameter(torch.ones(hidden_size)) self.variance_epsilon = eps ...
class OpenLlamaRMSNorm(nn.Module): def __init__(self, hidden_size, eps=1e-06): ''' OpenLlamaRMSNorm is equivalent to T5LayerNorm ''' pass def forward(self, hidden_states): pass def extra_repr(self): pass
4
1
5
0
4
1
1
0.23
1
2
0
0
3
2
3
13
18
2
13
8
9
3
13
8
9
1
1
0
3
1,891
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/open_llama/modeling_open_llama.py
transformers.models.deprecated.open_llama.modeling_open_llama.OpenLlamaRotaryEmbedding
from torch import nn import torch class OpenLlamaRotaryEmbedding(nn.Module): inv_freq: torch.Tensor cos_cached: torch.Tensor sin_cached: torch.Tensor def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None): super().__init__() self.dim = dim self.max_posit...
class OpenLlamaRotaryEmbedding(nn.Module): def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None): pass def _set_cos_sin_cache(self, seq_len, device, dtype): pass def forward(self, x, seq_len=None): pass
4
0
10
1
8
1
1
0.12
1
1
0
2
3
4
3
13
34
6
25
12
21
3
20
12
16
2
1
1
4
1,892
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/qdqbert/configuration_qdqbert.py
transformers.models.deprecated.qdqbert.configuration_qdqbert.QDQBertConfig
from ....configuration_utils import PretrainedConfig class QDQBertConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`QDQBertModel`]. It is used to instantiate an QDQBERT model according to the specified arguments, defining the model architecture. Instantiating a...
class QDQBertConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`QDQBertModel`]. It is used to instantiate an QDQBERT model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a sim...
2
1
35
1
34
0
1
1.39
1
1
0
0
1
13
1
33
97
11
36
35
15
50
17
16
15
1
2
0
1
1,893
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/qdqbert/modeling_qdqbert.py
transformers.models.deprecated.qdqbert.modeling_qdqbert.QDQBertAttention
from ....pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer from torch import nn from ....utils.deprecation import deprecate_kwarg class QDQBertAttention(nn.Module): def __init__(self, config): super().__init__() self.self = QDQBertSelfAttention(config) self.output =...
class QDQBertAttention(nn.Module): def __init__(self, config): pass def prune_heads(self, heads): pass @deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58') def forward(self, hidden_states, attention_mask=None, head_mask=None, encoder_hidden_states=None, encod...
5
0
15
1
13
1
1
0.07
1
4
2
0
3
3
3
13
47
4
41
20
28
3
22
11
18
2
1
1
4
1,894
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/qdqbert/modeling_qdqbert.py
transformers.models.deprecated.qdqbert.modeling_qdqbert.QDQBertEmbeddings
import torch from typing import Optional, Union from torch import nn class QDQBertEmbeddings(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.hi...
class QDQBertEmbeddings(nn.Module): '''Construct the embeddings from word, position and token_type embeddings.''' def __init__(self, config): pass def forward(self, input_ids: Optional[torch.LongTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, position_ids: Optional[torch.LongTensor...
3
1
29
3
23
3
4
0.15
1
3
0
0
2
6
2
12
62
8
47
23
37
7
34
16
31
7
1
2
8
1,895
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/qdqbert/modeling_qdqbert.py
transformers.models.deprecated.qdqbert.modeling_qdqbert.QDQBertEncoder
from torch import nn from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, NextSentencePredictorOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifie...
class QDQBertEncoder(nn.Module): def __init__(self, config): pass def forward(self, hidden_states, attention_mask=None, head_mask=None, encoder_hidden_states=None, encoder_attention_mask=None, past_key_values=None, use_cache=None, output_attentions=False, output_hidden_states=False, return_dict=True)...
3
0
44
3
41
0
9
0
1
6
2
0
2
3
2
12
89
7
82
26
67
0
34
14
31
16
1
3
17
1,896
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/qdqbert/modeling_qdqbert.py
transformers.models.deprecated.qdqbert.modeling_qdqbert.QDQBertForMaskedLM
import torch from typing import Optional, Union from ....utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, is_pytorch_quantization_available, logging, replace_return_docstrings, requires_backends from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ....
@add_start_docstrings('QDQBERT Model with a `language modeling` head on top.', QDQBERT_START_DOCSTRING) class QDQBertForMaskedLM(QDQBertPreTrainedModel): def __init__(self, config): pass def get_output_embeddings(self): pass def set_output_embeddings(self, new_embeddings): pass ...
9
1
18
2
14
2
2
0.11
1
6
3
0
5
2
5
135
105
17
80
35
52
9
36
18
30
5
3
1
11
1,897
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/qdqbert/modeling_qdqbert.py
transformers.models.deprecated.qdqbert.modeling_qdqbert.QDQBertForMultipleChoice
from torch import nn import torch from typing import Optional, Union from ....utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, is_pytorch_quantization_available, logging, replace_return_docstrings, requires_backends from torch.nn import BCEWithLogitsLoss, CrossEntrop...
@add_start_docstrings('\n Bert Model with a multiple choice classification head on top (a linear layer on top of the pooled output and a\n softmax) e.g. for RocStories/SWAG tasks.\n ', QDQBERT_START_DOCSTRING) class QDQBertForMultipleChoice(QDQBertPreTrainedModel): def __init__(self, config): pass...
6
1
37
5
29
4
6
0.11
1
4
2
0
2
3
2
132
82
10
65
27
44
7
28
14
25
11
3
1
12
1,898
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/qdqbert/modeling_qdqbert.py
transformers.models.deprecated.qdqbert.modeling_qdqbert.QDQBertForNextSentencePrediction
import torch from typing import Optional, Union from ....utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, is_pytorch_quantization_available, logging, replace_return_docstrings, requires_backends import warnings from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss...
@add_start_docstrings('Bert Model with a `next sentence prediction (classification)` head on top.', QDQBERT_START_DOCSTRING) class QDQBertForNextSentencePrediction(QDQBertPreTrainedModel): def __init__(self, config): pass @add_start_docstrings_to_model_forward(QDQBERT_INPUTS_DOCSTRING.format('batch_siz...
6
1
46
9
27
11
4
0.38
1
6
3
0
2
2
2
132
95
18
56
25
38
21
22
11
19
6
3
1
7
1,899
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/qdqbert/modeling_qdqbert.py
transformers.models.deprecated.qdqbert.modeling_qdqbert.QDQBertForQuestionAnswering
from typing import Optional, Union from ....utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, is_pytorch_quantization_available, logging, replace_return_docstrings, requires_backends from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ....modeling_o...
@add_start_docstrings('\n QDQBERT Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear\n layers on top of the hidden-states output to compute `span start logits` and `span end logits`).\n ', QDQBERT_START_DOCSTRING) class QDQBertForQuestionAnswering(QDQBertP...
6
1
41
5
30
7
4
0.19
1
4
2
0
2
3
2
132
90
10
67
30
45
13
32
16
29
7
3
2
8