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,300 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py | transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2VisualBackbone | import math
from torch import nn
import torch
class LayoutLMv2VisualBackbone(nn.Module):
def __init__(self, config):
super().__init__()
self.cfg = config.get_detectron2_config()
meta_arch = self.cfg.MODEL.META_ARCHITECTURE
model = META_ARCH_REGISTRY.get(meta_arch)(self.cfg)
... |
class LayoutLMv2VisualBackbone(nn.Module):
def __init__(self, config):
pass
def forward(self, images):
pass
def synchronize_batch_norm(self):
pass | 4 | 0 | 20 | 1 | 19 | 0 | 3 | 0 | 1 | 5 | 0 | 0 | 3 | 4 | 3 | 13 | 64 | 6 | 58 | 21 | 54 | 0 | 40 | 21 | 36 | 3 | 1 | 1 | 8 |
3,301 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/processing_layoutlmv2.py | transformers.models.layoutlmv2.processing_layoutlmv2.LayoutLMv2Processor | from ...processing_utils import ProcessorMixin
import warnings
from ...utils import TensorType
from typing import Optional, Union
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
class LayoutLMv2Processor(ProcessorMixin):
"""
Constructs a L... |
class LayoutLMv2Processor(ProcessorMixin):
'''
Constructs a LayoutLMv2 processor which combines a LayoutLMv2 image processor and a LayoutLMv2 tokenizer into a
single processor.
[`LayoutLMv2Processor`] offers all the functionalities you need to prepare data for the model.
It first uses [`LayoutLMv2I... | 10 | 2 | 18 | 2 | 13 | 3 | 3 | 0.33 | 1 | 8 | 2 | 0 | 8 | 0 | 8 | 25 | 175 | 24 | 114 | 42 | 80 | 38 | 52 | 17 | 43 | 10 | 2 | 2 | 23 |
3,302 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/tokenization_layoutlmv2.py | transformers.models.layoutlmv2.tokenization_layoutlmv2.LayoutLMv2Tokenizer | import collections
import os
from ...tokenization_utils_base import BatchEncoding, EncodedInput, PreTokenizedInput, TextInput, TextInputPair, TruncationStrategy
from ...tokenization_utils import AddedToken, PreTrainedTokenizer, _is_control, _is_punctuation, _is_whitespace
from typing import Optional, Union
from ...util... |
class LayoutLMv2Tokenizer(PreTrainedTokenizer):
'''
Construct a LayoutLMv2 tokenizer. Based on WordPiece. [`LayoutLMv2Tokenizer`] can be used to turn words, word-level
bounding boxes and optional word labels to token-level `input_ids`, `attention_mask`, `token_type_ids`, `bbox`, and
optional `labels` (... | 31 | 12 | 49 | 3 | 38 | 8 | 6 | 0.23 | 1 | 17 | 4 | 0 | 22 | 10 | 22 | 111 | 1,163 | 95 | 878 | 328 | 618 | 199 | 303 | 90 | 279 | 30 | 3 | 4 | 127 |
3,303 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/tokenization_layoutlmv2_fast.py | transformers.models.layoutlmv2.tokenization_layoutlmv2_fast.LayoutLMv2TokenizerFast | from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...tokenization_utils_base import BatchEncoding, EncodedInput, PaddingStrategy, PreTokenizedInput, TensorType, TextInput, TextInputPair, TruncationStrategy
from tokenizers import normalizers
from ...utils import add_end_docstrings, logging
import json
... |
class LayoutLMv2TokenizerFast(PreTrainedTokenizerFast):
'''
Construct a "fast" LayoutLMv2 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... | 15 | 5 | 60 | 4 | 46 | 10 | 7 | 0.29 | 1 | 15 | 2 | 0 | 11 | 6 | 11 | 99 | 761 | 60 | 547 | 208 | 386 | 156 | 185 | 60 | 172 | 24 | 3 | 6 | 81 |
3,304 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/configuration_layoutlmv3.py | transformers.models.layoutlmv3.configuration_layoutlmv3.LayoutLMv3Config | from ...configuration_utils import PretrainedConfig
class LayoutLMv3Config(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`LayoutLMv3Model`]. It is used to instantiate an
LayoutLMv3 model according to the specified arguments, defining the model architecture. Instant... |
class LayoutLMv3Config(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`LayoutLMv3Model`]. It is used to instantiate an
LayoutLMv3 model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yi... | 2 | 1 | 67 | 0 | 67 | 0 | 1 | 1.07 | 1 | 1 | 0 | 0 | 1 | 15 | 1 | 1 | 152 | 9 | 69 | 51 | 34 | 74 | 19 | 18 | 17 | 1 | 1 | 0 | 1 |
3,305 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/configuration_layoutlmv3.py | transformers.models.layoutlmv3.configuration_layoutlmv3.LayoutLMv3OnnxConfig | from typing import TYPE_CHECKING, Any
from collections.abc import Mapping
from ...onnx.utils import compute_effective_axis_dimension
from ...onnx import OnnxConfig
from collections import OrderedDict
from packaging import version
class LayoutLMv3OnnxConfig(OnnxConfig):
torch_onnx_minimum_version = version.parse('1... |
class LayoutLMv3OnnxConfig(OnnxConfig):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
pass
@property
def atol_for_validation(self) -> float:
pass
@property
def default_onnx_opset(self) -> int:
pass
def generate_dummy_inputs(self, processor: 'Proces... | 8 | 1 | 23 | 2 | 14 | 8 | 1 | 0.51 | 1 | 7 | 0 | 0 | 4 | 1 | 4 | 4 | 101 | 12 | 59 | 25 | 41 | 30 | 20 | 11 | 15 | 2 | 1 | 1 | 5 |
3,306 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/feature_extraction_layoutlmv3.py | transformers.models.layoutlmv3.feature_extraction_layoutlmv3.LayoutLMv3FeatureExtractor | import warnings
from ...utils.import_utils import requires
from .image_processing_layoutlmv3 import LayoutLMv3ImageProcessor
@requires(backends=('vision',))
class LayoutLMv3FeatureExtractor(LayoutLMv3ImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn('The class LayoutLMv3FeatureEx... | @requires(backends=('vision',))
class LayoutLMv3FeatureExtractor(LayoutLMv3ImageProcessor):
def __init__(self, *args, **kwargs) -> None:
pass | 3 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 24 | 8 | 0 | 8 | 2 | 6 | 0 | 4 | 2 | 2 | 1 | 4 | 0 | 1 |
3,307 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/image_processing_layoutlmv3.py | transformers.models.layoutlmv3.image_processing_layoutlmv3.LayoutLMv3ImageProcessor | from collections.abc import Iterable
from ...utils import TensorType, filter_out_non_signature_kwargs, is_pytesseract_available, is_vision_available, logging, requires_backends
from ...utils.import_utils import requires
from ...image_transforms import resize, to_channel_dimension_format, to_pil_image
from ...image_util... | @requires(backends=('vision',))
class LayoutLMv3ImageProcessor(BaseImageProcessor):
'''
Constructs a LayoutLMv3 image processor.
Args:
do_resize (`bool`, *optional*, defaults to `True`):
Whether to resize the image's (height, width) dimensions to `(size["height"], size["width"])`. Can be... | 6 | 3 | 76 | 5 | 45 | 26 | 9 | 0.83 | 1 | 8 | 2 | 1 | 3 | 11 | 3 | 23 | 272 | 20 | 138 | 61 | 94 | 114 | 65 | 21 | 61 | 21 | 3 | 2 | 27 |
3,308 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3Attention | import torch.nn as nn
class LayoutLMv3Attention(nn.Module):
def __init__(self, config):
super().__init__()
self.self = LayoutLMv3SelfAttention(config)
self.output = LayoutLMv3SelfOutput(config)
def forward(self, hidden_states, attention_mask=None, head_mask=None, output_attentions=Fal... |
class LayoutLMv3Attention(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states, attention_mask=None, head_mask=None, output_attentions=False, rel_pos=None, rel_2d_pos=None):
pass | 3 | 0 | 12 | 0 | 12 | 1 | 1 | 0.04 | 1 | 3 | 2 | 0 | 2 | 2 | 2 | 12 | 26 | 1 | 25 | 16 | 14 | 1 | 10 | 8 | 7 | 1 | 1 | 0 | 2 |
3,309 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3ClassificationHead | import torch
import torch.nn as nn
import torch.nn.functional as F
class LayoutLMv3ClassificationHead(nn.Module):
"""
Head for sentence-level classification tasks. Reference: RobertaClassificationHead
"""
def __init__(self, config, pool_feature=False):
super().__init__()
self.pool_feat... |
class LayoutLMv3ClassificationHead(nn.Module):
'''
Head for sentence-level classification tasks. Reference: RobertaClassificationHead
'''
def __init__(self, config, pool_feature=False):
pass
def forward(self, x):
pass | 3 | 1 | 10 | 0 | 10 | 0 | 2 | 0.15 | 1 | 1 | 0 | 0 | 2 | 4 | 2 | 12 | 25 | 2 | 20 | 8 | 17 | 3 | 17 | 8 | 14 | 3 | 1 | 1 | 4 |
3,310 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3Encoder | from ...modeling_outputs import BaseModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
import torch.nn as nn
import torch.nn.functional as F
import torch
import math
class LayoutLMv3Encoder(nn.Module):
def __init__(self, config):
super().__init__()
self.conf... |
class LayoutLMv3Encoder(nn.Module):
def __init__(self, config):
pass
def relative_position_bucket(self, relative_position, bidirectional=True, num_buckets=32, max_distance=128):
pass
def _cal_1d_pos_emb(self, position_ids):
pass
def _cal_2d_pos_emb(self, bbox):
pass
... | 6 | 0 | 30 | 3 | 25 | 2 | 4 | 0.09 | 1 | 6 | 2 | 0 | 5 | 12 | 5 | 15 | 155 | 18 | 126 | 51 | 108 | 11 | 71 | 39 | 65 | 12 | 1 | 2 | 19 |
3,311 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3ForQuestionAnswering | import torch.nn.functional as F
import torch.nn as nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from typing import Optional, Union
from ...modeling_outputs import BaseModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
import torch
from ...utils import auto... | @auto_docstring
class LayoutLMv3ForQuestionAnswering(LayoutLMv3PreTrainedModel):
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... | 5 | 1 | 57 | 9 | 32 | 17 | 4 | 0.48 | 1 | 5 | 3 | 0 | 2 | 3 | 2 | 3 | 120 | 18 | 69 | 34 | 47 | 33 | 32 | 16 | 29 | 7 | 2 | 2 | 8 |
3,312 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3ForSequenceClassification | from typing import Optional, Union
from ...modeling_outputs import BaseModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
import torch.nn as nn
import torch
from ...utils import auto_docstring, logging, torch_int
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
i... | @auto_docstring(custom_intro='\n LayoutLMv3 Model with a sequence classification head on top (a linear layer on top of the final hidden state of the\n [CLS] token) e.g. for document image classification tasks such as the\n [RVL-CDIP](https://www.cs.cmu.edu/~aharley/rvl-cdip/) dataset.\n ')
class LayoutLMv3F... | 5 | 1 | 51 | 7 | 34 | 10 | 7 | 0.27 | 1 | 6 | 3 | 0 | 2 | 4 | 2 | 3 | 107 | 14 | 73 | 30 | 52 | 20 | 33 | 13 | 30 | 12 | 2 | 3 | 13 |
3,313 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3ForTokenClassification | import torch.nn as nn
from ...modeling_outputs import BaseModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...utils import auto_docstring, logging, torch_int
import torch.nn.functional as F
import torch
from... | @auto_docstring(custom_intro='\n LayoutLMv3 Model with a token classification head on top (a linear layer on top of the final hidden states) e.g.\n for sequence labeling (information extraction) tasks such as [FUNSD](https://guillaumejaume.github.io/FUNSD/),\n [SROIE](https://rrc.cvc.uab.es/?ch=13), [CORD](htt... | 5 | 1 | 48 | 7 | 30 | 11 | 4 | 0.34 | 1 | 5 | 3 | 0 | 2 | 4 | 2 | 3 | 102 | 15 | 65 | 32 | 44 | 22 | 28 | 15 | 25 | 6 | 2 | 1 | 8 |
3,314 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3Intermediate | import torch.nn as nn
import torch
from ...activations import ACT2FN
import torch.nn.functional as F
class LayoutLMv3Intermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act,... |
class LayoutLMv3Intermediate(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,315 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3Layer | from ...modeling_layers import GradientCheckpointingLayer
from ...pytorch_utils import apply_chunking_to_forward
class LayoutLMv3Layer(GradientCheckpointingLayer):
def __init__(self, config):
super().__init__()
self.chunk_size_feed_forward = config.chunk_size_feed_forward
self.seq_len_dim ... |
class LayoutLMv3Layer(GradientCheckpointingLayer):
def __init__(self, config):
pass
def forward(self, hidden_states, attention_mask=None, head_mask=None, output_attentions=False, rel_pos=None, rel_2d_pos=None):
pass
def feed_forward_chunk(self, attention_output):
pass | 4 | 0 | 13 | 1 | 12 | 0 | 1 | 0.03 | 1 | 4 | 3 | 0 | 3 | 5 | 3 | 13 | 41 | 5 | 36 | 23 | 24 | 1 | 19 | 15 | 15 | 1 | 1 | 0 | 3 |
3,316 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3Model | import torch
import torch.nn.functional as F
from ...utils import auto_docstring, logging, torch_int
from typing import Optional, Union
from ...modeling_outputs import BaseModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
import torch.nn as nn
@auto_docstring
class LayoutLMv3Mo... | @auto_docstring
class LayoutLMv3Model(LayoutLMv3PreTrainedModel):
def __init__(self, config):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, value):
pass
def _prune_heads(self, heads_to_prune):
'''
Prunes heads of the model. heads_to_... | 11 | 3 | 30 | 4 | 21 | 4 | 4 | 0.19 | 1 | 11 | 4 | 0 | 8 | 11 | 8 | 9 | 249 | 40 | 176 | 59 | 150 | 33 | 107 | 43 | 98 | 22 | 2 | 4 | 34 |
3,317 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3Output | import torch.nn.functional as F
import torch
import torch.nn as nn
class LayoutLMv3Output(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_... |
class LayoutLMv3Output(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,318 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3PatchEmbeddings | import collections
import torch.nn.functional as F
import torch.nn as nn
class LayoutLMv3PatchEmbeddings(nn.Module):
"""LayoutLMv3 image (patch) embeddings. This class also automatically interpolates the position embeddings for varying
image sizes."""
def __init__(self, config):
super().__init__()... |
class LayoutLMv3PatchEmbeddings(nn.Module):
'''LayoutLMv3 image (patch) embeddings. This class also automatically interpolates the position embeddings for varying
image sizes.'''
def __init__(self, config):
pass
def forward(self, pixel_values, position_embedding=None):
pass | 3 | 1 | 14 | 2 | 12 | 1 | 3 | 0.12 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 33 | 5 | 25 | 9 | 22 | 3 | 17 | 9 | 14 | 3 | 1 | 1 | 5 |
3,319 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3PreTrainedModel | from ...modeling_utils import PreTrainedModel
from ...utils import auto_docstring, logging, torch_int
import torch.nn as nn
from .configuration_layoutlmv3 import LayoutLMv3Config
@auto_docstring
class LayoutLMv3PreTrainedModel(PreTrainedModel):
config: LayoutLMv3Config
base_model_prefix = 'layoutlmv3'
def... | @auto_docstring
class LayoutLMv3PreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 15 | 0 | 12 | 3 | 6 | 0.47 | 1 | 0 | 0 | 4 | 1 | 0 | 1 | 1 | 24 | 2 | 15 | 4 | 13 | 7 | 13 | 4 | 11 | 6 | 1 | 2 | 6 |
3,320 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3SelfAttention | import torch.nn.functional as F
import math
import torch.nn as nn
import torch
class LayoutLMv3SelfAttention(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(... |
class LayoutLMv3SelfAttention(nn.Module):
def __init__(self, config):
pass
def cogview_attention(self, attention_scores, alpha=32):
'''
https://huggingface.co/papers/2105.13290 Section 2.4 Stabilization of training: Precision Bottleneck Relaxation
(PB-Relax). A replacement of ... | 4 | 1 | 21 | 4 | 14 | 4 | 3 | 0.27 | 1 | 3 | 0 | 0 | 4 | 9 | 4 | 14 | 88 | 17 | 56 | 35 | 43 | 15 | 44 | 27 | 39 | 6 | 1 | 1 | 10 |
3,321 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3SelfOutput | import torch.nn as nn
import torch
import torch.nn.functional as F
class LayoutLMv3SelfOutput(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_ep... |
class LayoutLMv3SelfOutput(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,322 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | transformers.models.layoutlmv3.modeling_layoutlmv3.LayoutLMv3TextEmbeddings | import torch.nn as nn
import torch
import torch.nn.functional as F
class LayoutLMv3TextEmbeddings(nn.Module):
"""
LayoutLMv3 text embeddings. Same as `RobertaEmbeddings` but with added spatial (layout) embeddings.
"""
def __init__(self, config):
super().__init__()
self.word_embeddings ... |
class LayoutLMv3TextEmbeddings(nn.Module):
'''
LayoutLMv3 text embeddings. Same as `RobertaEmbeddings` but with added spatial (layout) embeddings.
'''
def __init__(self, config):
pass
def calculate_spatial_position_embeddings(self, bbox):
pass
def create_position_ids_from_inp... | 6 | 3 | 21 | 3 | 16 | 2 | 2 | 0.17 | 1 | 2 | 0 | 0 | 5 | 10 | 5 | 15 | 116 | 19 | 83 | 41 | 70 | 14 | 56 | 33 | 50 | 6 | 1 | 2 | 11 |
3,323 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/processing_layoutlmv3.py | transformers.models.layoutlmv3.processing_layoutlmv3.LayoutLMv3Processor | import warnings
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from typing import Optional, Union
from ...utils import TensorType
class LayoutLMv3Processor(ProcessorMixin):
"""
Constructs a L... |
class LayoutLMv3Processor(ProcessorMixin):
'''
Constructs a LayoutLMv3 processor which combines a LayoutLMv3 image processor and a LayoutLMv3 tokenizer into a
single processor.
[`LayoutLMv3Processor`] offers all the functionalities you need to prepare data for the model.
It first uses [`LayoutLMv3I... | 10 | 2 | 17 | 1 | 13 | 3 | 3 | 0.35 | 1 | 8 | 2 | 0 | 8 | 0 | 8 | 25 | 173 | 23 | 112 | 42 | 78 | 39 | 50 | 17 | 41 | 9 | 2 | 2 | 22 |
3,324 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/tokenization_layoutlmv3.py | transformers.models.layoutlmv3.tokenization_layoutlmv3.LayoutLMv3Tokenizer | from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from typing import Optional, Union
import json
from ...utils import PaddingStrategy, TensorType, add_end_docstrings, logging
from ...tokenization_utils_base import BatchEncoding, EncodedInput, PreTokenizedInput, TextInput, TextInputPair, TruncationStrate... |
class LayoutLMv3Tokenizer(PreTrainedTokenizer):
'''
Construct a LayoutLMv3 tokenizer. Based on [`RoBERTatokenizer`] (Byte Pair Encoding or BPE).
[`LayoutLMv3Tokenizer`] can be used to turn words, word-level bounding boxes and optional word labels to
token-level `input_ids`, `attention_mask`, `token_typ... | 32 | 14 | 50 | 3 | 39 | 8 | 6 | 0.3 | 1 | 16 | 2 | 0 | 23 | 14 | 23 | 112 | 1,301 | 113 | 925 | 345 | 667 | 274 | 357 | 107 | 332 | 32 | 3 | 4 | 137 |
3,325 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv3/tokenization_layoutlmv3_fast.py | transformers.models.layoutlmv3.tokenization_layoutlmv3_fast.LayoutLMv3TokenizerFast | from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import add_end_docstrings, logging
from ...tokenization_utils_base import BatchEncoding, EncodedInput, PaddingStrategy, PreTokenizedInput, TensorType, TextInput, TextInputPair, TruncationStrategy
from .tokenization_layoutlmv3 import LAYOUTLMV3... |
class LayoutLMv3TokenizerFast(PreTrainedTokenizerFast):
'''
Construct a "fast" LayoutLMv3 tokenizer (backed by HuggingFace's *tokenizers* library). Based on BPE.
This tokenizer inherits from [`PreTrainedTokenizerFast`] which contains most of the main methods. Users should
refer to this superclass for m... | 16 | 5 | 60 | 4 | 48 | 9 | 7 | 0.29 | 1 | 15 | 2 | 0 | 11 | 5 | 11 | 99 | 797 | 67 | 568 | 216 | 404 | 164 | 202 | 65 | 189 | 25 | 3 | 6 | 87 |
3,326 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutxlm/processing_layoutxlm.py | transformers.models.layoutxlm.processing_layoutxlm.LayoutXLMProcessor | from ...utils import TensorType
from ...processing_utils import ProcessorMixin
from typing import Optional, Union
import warnings
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
class LayoutXLMProcessor(ProcessorMixin):
"""
Constructs a La... |
class LayoutXLMProcessor(ProcessorMixin):
'''
Constructs a LayoutXLM processor which combines a LayoutXLM image processor and a LayoutXLM tokenizer into a single
processor.
[`LayoutXLMProcessor`] offers all the functionalities you need to prepare data for the model.
It first uses [`LayoutLMv2ImageP... | 10 | 2 | 18 | 2 | 13 | 3 | 3 | 0.33 | 1 | 8 | 2 | 0 | 8 | 0 | 8 | 25 | 175 | 24 | 114 | 42 | 80 | 38 | 51 | 17 | 42 | 10 | 2 | 2 | 23 |
3,327 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutxlm/tokenization_layoutxlm.py | transformers.models.layoutxlm.tokenization_layoutxlm.LayoutXLMTokenizer | from ..xlm_roberta.tokenization_xlm_roberta import SPIECE_UNDERLINE, VOCAB_FILES_NAMES
import sentencepiece as spm
from shutil import copyfile
from ...tokenization_utils_base import BatchEncoding, EncodedInput, PreTokenizedInput, TextInput, TextInputPair, TruncationStrategy
from ...utils.import_utils import requires
fr... | @requires(backends=('sentencepiece',))
class LayoutXLMTokenizer(PreTrainedTokenizer):
'''
Adapted from [`RobertaTokenizer`] and [`XLNetTokenizer`]. Based on
[SentencePiece](https://github.com/google/sentencepiece).
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main meth... | 27 | 12 | 46 | 4 | 33 | 9 | 6 | 0.35 | 1 | 15 | 2 | 0 | 20 | 11 | 20 | 109 | 1,041 | 113 | 692 | 246 | 512 | 245 | 303 | 86 | 281 | 29 | 3 | 4 | 120 |
3,328 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutxlm/tokenization_layoutxlm_fast.py | transformers.models.layoutxlm.tokenization_layoutxlm_fast.LayoutXLMTokenizerFast | from shutil import copyfile
import os
from ...tokenization_utils_base import BatchEncoding, EncodedInput, PreTokenizedInput, TextInput, TextInputPair, TruncationStrategy
from ...utils import PaddingStrategy, TensorType, add_end_docstrings, is_sentencepiece_available, logging
from ...tokenization_utils import AddedToken... |
class LayoutXLMTokenizerFast(PreTrainedTokenizerFast):
'''
Construct a "fast" LayoutXLM tokenizer (backed by HuggingFace's *tokenizers* library). Adapted from
[`RobertaTokenizer`] and [`XLNetTokenizer`]. Based on
[BPE](https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=BPE#m... | 12 | 5 | 55 | 4 | 41 | 10 | 8 | 0.34 | 1 | 15 | 2 | 0 | 10 | 6 | 10 | 98 | 668 | 70 | 448 | 158 | 335 | 152 | 186 | 57 | 174 | 24 | 3 | 6 | 85 |
3,329 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/configuration_led.py | transformers.models.led.configuration_led.LEDConfig | from typing import Union
from ...configuration_utils import PretrainedConfig
class LEDConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`LEDModel`]. It is used to instantiate an LED
model according to the specified arguments, defining the model architecture. Ins... |
class LEDConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`LEDModel`]. It is used to instantiate an LED
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configu... | 2 | 1 | 59 | 1 | 58 | 0 | 1 | 0.91 | 1 | 2 | 0 | 0 | 1 | 21 | 1 | 1 | 137 | 11 | 66 | 53 | 36 | 60 | 26 | 25 | 24 | 1 | 1 | 0 | 1 |
3,330 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDClassificationHead | import torch
from torch import nn
class LEDClassificationHead(nn.Module):
"""Head for sentence-level classification tasks."""
def __init__(self, input_dim: int, inner_dim: int, num_classes: int, pooler_dropout: float):
super().__init__()
self.dense = nn.Linear(input_dim, inner_dim)
sel... |
class LEDClassificationHead(nn.Module):
'''Head for sentence-level classification tasks.'''
def __init__(self, input_dim: int, inner_dim: int, num_classes: int, pooler_dropout: float):
pass
def forward(self, hidden_states: torch.Tensor):
pass | 3 | 1 | 9 | 0 | 9 | 0 | 1 | 0.05 | 1 | 4 | 0 | 0 | 2 | 3 | 2 | 12 | 22 | 2 | 19 | 12 | 10 | 1 | 13 | 6 | 10 | 1 | 1 | 0 | 2 |
3,331 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDDecoder | from torch import nn
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions
from .configuration_led import LEDConfig
from typing import Optional, Union
from ...modeling_attn_mask_utils import _create_4d_causal_attention_... |
class LEDDecoder(LEDPreTrainedModel):
'''
Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`LEDDecoderLayer`]
Args:
config: LEDConfig
embed_tokens (nn.Embedding): output embedding
'''
def __init__(self, config: LEDConfig, embed_tokens: Optional[nn.... | 3 | 2 | 126 | 18 | 72 | 37 | 20 | 0.56 | 1 | 10 | 4 | 0 | 2 | 9 | 2 | 4 | 262 | 38 | 144 | 42 | 126 | 80 | 75 | 27 | 72 | 38 | 2 | 3 | 40 |
3,332 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDDecoderAttention | from torch import nn
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from ...utils.deprecation import deprecate_kwarg
class LEDDecoderAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self,... |
class LEDDecoderAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, embed_dim: int, num_heads: int, dropout: Optional[float]=0.0, is_decoder: Optional[bool]=False, bias: Optional[bool]=True, layer_idx: Optional[bool]=None):
pass
@deprecate_k... | 4 | 2 | 45 | 5 | 33 | 7 | 5 | 0.21 | 1 | 6 | 0 | 0 | 3 | 10 | 3 | 13 | 141 | 19 | 101 | 40 | 82 | 21 | 64 | 25 | 60 | 12 | 1 | 2 | 15 |
3,333 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDDecoderLayer | from torch import nn
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from .configuration_led import LEDConfig
from ...activations import ACT2FN
from typing import Optional, Union
from ...modeling_layers import GradientCheckpointingLayer
from ...utils.deprecation import deprecate_kwarg
... |
class LEDDecoderLayer(GradientCheckpointingLayer):
def __init__(self, config: LEDConfig, layer_idx=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]=None, encoder_hidden_s... | 4 | 1 | 56 | 6 | 39 | 12 | 4 | 0.31 | 1 | 5 | 2 | 0 | 2 | 11 | 2 | 12 | 114 | 12 | 78 | 32 | 64 | 24 | 44 | 21 | 41 | 6 | 1 | 1 | 7 |
3,334 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDEncoder | from .configuration_led import LEDConfig
import torch
from typing import Optional, Union
from torch import nn
class LEDEncoder(LEDPreTrainedModel):
"""
Transformer encoder consisting of *config.encoder_layers* self-attention layers. Each layer is a
[`LEDEncoderLayer`].
Args:
config: LEDConfig
... |
class LEDEncoder(LEDPreTrainedModel):
'''
Transformer encoder consisting of *config.encoder_layers* self-attention layers. Each layer is a
[`LEDEncoderLayer`].
Args:
config: LEDConfig
embed_tokens (nn.Embedding): output embedding
'''
def __init__(self, config: LEDConfig, embed_... | 5 | 3 | 69 | 9 | 45 | 16 | 11 | 0.39 | 1 | 11 | 4 | 0 | 4 | 9 | 4 | 6 | 288 | 40 | 180 | 50 | 159 | 71 | 104 | 34 | 99 | 30 | 2 | 3 | 45 |
3,335 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDEncoderAttention | import torch
from typing import Optional, Union
from torch import nn
class LEDEncoderAttention(nn.Module):
def __init__(self, config, layer_id):
super().__init__()
self.longformer_self_attn = LEDEncoderSelfAttention(config, layer_id=layer_id)
self.output = nn.Linear(config.d_model, config.... |
class LEDEncoderAttention(nn.Module):
def __init__(self, config, layer_id):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, layer_head_mask: Optional[torch.Tensor]=None, is_index_masked: Optional[torch.Tensor]=None, is_index_global_attn: Optional[torch... | 3 | 1 | 15 | 2 | 13 | 1 | 1 | 0.04 | 1 | 4 | 1 | 0 | 2 | 2 | 2 | 12 | 32 | 4 | 27 | 17 | 15 | 1 | 10 | 8 | 7 | 1 | 1 | 0 | 2 |
3,336 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDEncoderBaseModelOutput | 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 LEDEncoder's outputs, with potential hidden states, local and global attentions.\n ")
class LEDEncoderBaseModelOut... | @dataclass
@auto_docstring(custom_intro="\n Base class for LEDEncoder's outputs, with potential hidden states, local and global attentions.\n ")
class LEDEncoderBaseModelOutput(ModelOutput):
'''
attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `c... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 6 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 40 | 5 | 5 | 4 | 4 | 30 | 5 | 4 | 4 | 0 | 1 | 0 | 0 |
3,337 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDEncoderLayer | from torch import nn
import torch
from .configuration_led import LEDConfig
from ...activations import ACT2FN
from ...modeling_layers import GradientCheckpointingLayer
class LEDEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: LEDConfig, layer_id: int):
super().__init__()
self.em... |
class LEDEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: LEDConfig, layer_id: int):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, layer_head_mask: torch.Tensor, is_index_masked=None, is_index_global_attn=None, is_global_attn=None, output_attent... | 3 | 1 | 29 | 1 | 24 | 4 | 2 | 0.16 | 1 | 5 | 2 | 0 | 2 | 9 | 2 | 12 | 60 | 3 | 49 | 24 | 37 | 8 | 30 | 15 | 27 | 2 | 1 | 1 | 3 |
3,338 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDEncoderSelfAttention | import math
import torch
from torch import nn
class LEDEncoderSelfAttention(nn.Module):
def __init__(self, config, layer_id):
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 n... | null | 18 | 7 | 51 | 8 | 33 | 11 | 2 | 0.33 | 1 | 8 | 0 | 0 | 7 | 13 | 12 | 22 | 633 | 101 | 407 | 131 | 354 | 135 | 191 | 88 | 178 | 7 | 1 | 1 | 22 |
3,339 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDForConditionalGeneration | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...generation import GenerationMixin
from ...utils import ModelOutput, auto_docstring, logging
from torch import nn
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from .configuration_led import LEDConfig
from typing... | @auto_docstring(custom_intro='\n The LED Model with a language modeling head. Can be used for summarization.\n ')
class LEDForConditionalGeneration(LEDPreTrainedModel, GenerationMixin):
def __init__(self, config: LEDConfig):
pass
def get_encoder(self):
pass
def get_decoder(self):
... | 10 | 1 | 14 | 1 | 11 | 2 | 2 | 0.16 | 2 | 8 | 3 | 0 | 9 | 3 | 10 | 12 | 153 | 22 | 113 | 51 | 77 | 18 | 54 | 27 | 43 | 8 | 2 | 2 | 19 |
3,340 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDForQuestionAnswering | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...utils import ModelOutput, auto_docstring, logging
from torch import nn
import torch
from typing import Optional, Union
@auto_docstring
class LEDForQuestionAnswering(LEDPreTrainedModel):
_tied_weights_keys = ['decoder.embed_tokens.weight', 'e... | @auto_docstring
class LEDForQuestionAnswering(LEDPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.Tensor]=None, decoder_input_ids: Optional[torch.LongTensor]=None, decoder_attention_mask: ... | 5 | 1 | 54 | 5 | 42 | 7 | 5 | 0.14 | 1 | 5 | 2 | 0 | 2 | 3 | 2 | 4 | 117 | 12 | 92 | 37 | 64 | 13 | 36 | 17 | 33 | 8 | 2 | 2 | 9 |
3,341 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDForSequenceClassification | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
import warnings
from ...utils import ModelOutput, auto_docstring, logging
import torch
from .configuration_led import LEDConfig
from typing import Optional, Union
@auto_docstring(custom_intro='\n LED model with a sequence classification/head on top (... | @auto_docstring(custom_intro='\n LED model with a sequence classification/head on top (a linear layer on top of the pooled output) e.g. for GLUE\n tasks.\n ')
class LEDForSequenceClassification(LEDPreTrainedModel):
def __init__(self, config: LEDConfig, **kwargs):
pass
@auto_docstring
def f... | 5 | 1 | 59 | 4 | 52 | 4 | 8 | 0.06 | 1 | 11 | 4 | 0 | 2 | 2 | 2 | 4 | 127 | 10 | 111 | 33 | 84 | 7 | 41 | 14 | 38 | 15 | 2 | 3 | 16 |
3,342 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDLearnedPositionalEmbedding | import torch
from torch import nn
class LEDLearnedPositionalEmbedding(nn.Embedding):
"""
This module learns positional embeddings up to a fixed maximum size.
"""
def __init__(self, num_embeddings: int, embedding_dim: int):
super().__init__(num_embeddings, embedding_dim)
def forward(self, ... |
class LEDLearnedPositionalEmbedding(nn.Embedding):
'''
This module learns positional embeddings up to a fixed maximum size.
'''
def __init__(self, num_embeddings: int, embedding_dim: int):
pass
def forward(self, input_ids_shape: torch.Size, past_key_values_length: int=0):
'''`inpu... | 3 | 2 | 5 | 0 | 4 | 1 | 1 | 0.44 | 1 | 2 | 0 | 0 | 2 | 0 | 2 | 2 | 15 | 2 | 9 | 5 | 6 | 4 | 7 | 5 | 4 | 1 | 1 | 0 | 2 |
3,343 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDModel | from ...utils import ModelOutput, auto_docstring, logging
from torch import nn
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from .configuration_led import LEDConfig
from typing import Optional, Union
@auto_docstring
class LEDModel(LEDPreTrainedModel):
_tied_weights_keys = ['deco... | @auto_docstring
class LEDModel(LEDPreTrainedModel):
def __init__(self, config: LEDConfig):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, value):
pass
def get_encoder(self):
pass
@auto_docstring
def forward(self, input_ids: Optional[t... | 8 | 1 | 18 | 1 | 15 | 1 | 3 | 0.06 | 1 | 8 | 5 | 0 | 6 | 3 | 6 | 8 | 119 | 14 | 99 | 32 | 68 | 6 | 33 | 13 | 26 | 12 | 2 | 1 | 17 |
3,344 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDPreTrainedModel | from ...utils import ModelOutput, auto_docstring, logging
from torch import nn
from ...modeling_utils import PreTrainedModel
import torch
from .configuration_led import LEDConfig
@auto_docstring
class LEDPreTrainedModel(PreTrainedModel):
config: LEDConfig
base_model_prefix = 'led'
supports_gradient_checkpo... | @auto_docstring
class LEDPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
pass
@property
def dummy_inputs(self):
pass | 5 | 0 | 9 | 0 | 9 | 0 | 3 | 0 | 1 | 0 | 0 | 6 | 2 | 0 | 2 | 2 | 25 | 2 | 23 | 11 | 19 | 0 | 18 | 10 | 15 | 5 | 1 | 2 | 6 |
3,345 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDSeq2SeqLMOutput | from ...utils import ModelOutput, auto_docstring, logging
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from dataclasses import dataclass
@dataclass
@auto_docstring(custom_intro='\n Base class for sequence-to-sequence language models outputs.\n ... | @dataclass
@auto_docstring(custom_intro='\n Base class for sequence-to-sequence language models outputs.\n ')
class LEDSeq2SeqLMOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Language modeling loss.
logits (`torch.FloatTenso... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 4 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 64 | 9 | 11 | 11 | 10 | 44 | 11 | 11 | 10 | 0 | 1 | 0 | 0 |
3,346 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDSeq2SeqModelOutput | from ...utils import ModelOutput, auto_docstring, logging
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from dataclasses import dataclass
@dataclass
@auto_docstring(custom_intro="\n Base class for model encoder's outputs that also contains : pre-... | @dataclass
@auto_docstring(custom_intro="\n Base class for model encoder's outputs that also contains : pre-computed hidden states that can speed up sequential\n decoding.\n ")
class LEDSeq2SeqModelOutput(ModelOutput):
'''
last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, h... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 4.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 65 | 10 | 10 | 10 | 9 | 45 | 10 | 10 | 9 | 0 | 1 | 0 | 0 |
3,347 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDSeq2SeqQuestionAnsweringModelOutput | from dataclasses import dataclass
from ...utils import ModelOutput, auto_docstring, logging
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
@dataclass
@auto_docstring(custom_intro='\n Base class for outputs of sequence-to-sequence question answerin... | @dataclass
@auto_docstring(custom_intro='\n Base class for outputs of sequence-to-sequence question answering models.\n ')
class LEDSeq2SeqQuestionAnsweringModelOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Total span extractio... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.83 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 67 | 9 | 12 | 12 | 11 | 46 | 12 | 12 | 11 | 0 | 1 | 0 | 0 |
3,348 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/modeling_led.py | transformers.models.led.modeling_led.LEDSeq2SeqSequenceClassifierOutput | from dataclasses import dataclass
from ...utils import ModelOutput, auto_docstring, logging
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
@dataclass
@auto_docstring(custom_intro='\n Base class for outputs of sequence-to-sequence sentence classifi... | @dataclass
@auto_docstring(custom_intro='\n Base class for outputs of sequence-to-sequence sentence classification models.\n ')
class LEDSeq2SeqSequenceClassifierOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `label` is provided):
Classification (or r... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 4 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 64 | 9 | 11 | 11 | 10 | 44 | 11 | 11 | 10 | 0 | 1 | 0 | 0 |
3,349 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/tokenization_led.py | transformers.models.led.tokenization_led.LEDTokenizer | from ...utils import PaddingStrategy, logging
from ...tokenization_utils import AddedToken, PreTrainedTokenizer
import os
from typing import Optional, Union
import regex as re
import json
from ...tokenization_utils_base import BatchEncoding, EncodedInput
class LEDTokenizer(PreTrainedTokenizer):
"""
Constructs ... |
class LEDTokenizer(PreTrainedTokenizer):
'''
Constructs a LED tokenizer, which is smilar to the ROBERTa 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... | 16 | 8 | 19 | 2 | 14 | 4 | 3 | 0.6 | 1 | 12 | 1 | 0 | 14 | 9 | 14 | 103 | 374 | 57 | 200 | 82 | 156 | 120 | 134 | 49 | 119 | 9 | 3 | 3 | 45 |
3,350 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/led/tokenization_led_fast.py | transformers.models.led.tokenization_led_fast.LEDTokenizerFast | from tokenizers import processors
from ...utils import PaddingStrategy, logging
from .tokenization_led import LEDTokenizer
import json
from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput
from typing import Optional, Union
from ...tokenization_utils_fast import PreTrainedTokenizerFast
class L... |
class LEDTokenizerFast(PreTrainedTokenizerFast):
'''
Construct a "fast" LED tokenizer (backed by HuggingFace's *tokenizers* library), 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... | 12 | 4 | 20 | 2 | 15 | 3 | 3 | 0.71 | 1 | 8 | 1 | 0 | 9 | 1 | 9 | 97 | 286 | 49 | 139 | 57 | 101 | 98 | 73 | 29 | 63 | 8 | 3 | 3 | 28 |
3,351 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/configuration_levit.py | transformers.models.levit.configuration_levit.LevitConfig | from ...configuration_utils import PretrainedConfig
class LevitConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`LevitModel`]. It is used to instantiate a LeViT
model according to the specified arguments, defining the model architecture. Instantiating a configu... |
class LevitConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`LevitModel`]. It is used to instantiate a LeViT
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar co... | 2 | 1 | 37 | 0 | 37 | 0 | 1 | 1.21 | 1 | 1 | 0 | 0 | 1 | 15 | 1 | 1 | 95 | 9 | 39 | 35 | 20 | 47 | 19 | 18 | 17 | 1 | 1 | 0 | 1 |
3,352 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/configuration_levit.py | transformers.models.levit.configuration_levit.LevitOnnxConfig | from packaging import version
from ...onnx import OnnxConfig
from collections import OrderedDict
from collections.abc import Mapping
class LevitOnnxConfig(OnnxConfig):
torch_onnx_minimum_version = version.parse('1.11')
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
return OrderedDi... |
class LevitOnnxConfig(OnnxConfig):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
pass
@property
def atol_for_validation(self) -> float:
pass | 5 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 4 | 0 | 0 | 2 | 0 | 2 | 2 | 14 | 2 | 12 | 6 | 7 | 0 | 6 | 4 | 3 | 1 | 1 | 0 | 2 |
3,353 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/feature_extraction_levit.py | transformers.models.levit.feature_extraction_levit.LevitFeatureExtractor | from .image_processing_levit import LevitImageProcessor
from ...utils.import_utils import requires
import warnings
@requires(backends=('vision',))
class LevitFeatureExtractor(LevitImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn('The class LevitFeatureExtractor is deprecated and... | @requires(backends=('vision',))
class LevitFeatureExtractor(LevitImageProcessor):
def __init__(self, *args, **kwargs) -> None:
pass | 3 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 24 | 8 | 0 | 8 | 2 | 6 | 0 | 4 | 2 | 2 | 1 | 4 | 0 | 1 |
3,354 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/image_processing_levit.py | transformers.models.levit.image_processing_levit.LevitImageProcessor | from typing import Optional, Union
from ...utils.import_utils import requires
from collections.abc import Iterable
from ...image_transforms import get_resize_output_image_size, resize, to_channel_dimension_format
from ...utils import TensorType, filter_out_non_signature_kwargs, logging
from ...image_utils import IMAGEN... | @requires(backends=('vision',))
class LevitImageProcessor(BaseImageProcessor):
'''
Constructs a LeViT image processor.
Args:
do_resize (`bool`, *optional*, defaults to `True`):
Wwhether to resize the shortest edge of the input to int(256/224 *`size`). Can be overridden by the
... | 6 | 3 | 72 | 5 | 42 | 25 | 9 | 0.85 | 1 | 8 | 2 | 1 | 3 | 10 | 3 | 23 | 261 | 20 | 130 | 57 | 88 | 111 | 60 | 19 | 56 | 18 | 3 | 1 | 26 |
3,355 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitAttention | import itertools
import torch
from torch import nn
class LevitAttention(nn.Module):
def __init__(self, hidden_sizes, key_dim, num_attention_heads, attention_ratio, resolution):
super().__init__()
self.num_attention_heads = num_attention_heads
self.scale = key_dim ** (-0.5)
self.key... |
class LevitAttention(nn.Module):
def __init__(self, hidden_sizes, key_dim, num_attention_heads, attention_ratio, resolution):
pass
@torch.no_grad()
def train(self, mode=True):
pass
def get_attention_biases(self, device):
pass
def forward(self, hidden_state):
pass | 6 | 0 | 14 | 1 | 13 | 0 | 3 | 0.02 | 1 | 6 | 1 | 0 | 4 | 11 | 4 | 14 | 60 | 7 | 53 | 28 | 47 | 1 | 47 | 27 | 42 | 4 | 1 | 3 | 10 |
3,356 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitAttentionSubsample | from torch import nn
import itertools
import torch
class LevitAttentionSubsample(nn.Module):
def __init__(self, input_dim, output_dim, key_dim, num_attention_heads, attention_ratio, stride, resolution_in, resolution_out):
super().__init__()
self.num_attention_heads = num_attention_heads
se... |
class LevitAttentionSubsample(nn.Module):
def __init__(self, input_dim, output_dim, key_dim, num_attention_heads, attention_ratio, stride, resolution_in, resolution_out):
pass
@torch.no_grad()
def train(self, mode=True):
pass
def get_attention_biases(self, device):
pass
d... | 6 | 0 | 19 | 1 | 18 | 1 | 3 | 0.03 | 1 | 7 | 2 | 0 | 4 | 14 | 4 | 14 | 81 | 8 | 72 | 43 | 56 | 2 | 52 | 32 | 47 | 4 | 1 | 3 | 10 |
3,357 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitClassificationLayer | from torch import nn
class LevitClassificationLayer(nn.Module):
"""
LeViT Classification Layer
"""
def __init__(self, input_dim, output_dim):
super().__init__()
self.batch_norm = nn.BatchNorm1d(input_dim)
self.linear = nn.Linear(input_dim, output_dim)
def forward(self, hid... |
class LevitClassificationLayer(nn.Module):
'''
LeViT Classification Layer
'''
def __init__(self, input_dim, output_dim):
pass
def forward(self, hidden_state):
pass | 3 | 1 | 4 | 0 | 4 | 0 | 1 | 0.33 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 14 | 2 | 9 | 6 | 6 | 3 | 9 | 6 | 6 | 1 | 1 | 0 | 2 |
3,358 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitConvEmbeddings | from torch import nn
class LevitConvEmbeddings(nn.Module):
"""
LeViT Conv Embeddings with Batch Norm, used in the initial patch embedding layer.
"""
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, dilation=1, groups=1, bn_weight_init=1):
super().__init__()
s... |
class LevitConvEmbeddings(nn.Module):
'''
LeViT Conv Embeddings with Batch Norm, used in the initial patch embedding layer.
'''
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, dilation=1, groups=1, bn_weight_init=1):
pass
def forward(self, embeddings):
... | 3 | 1 | 6 | 0 | 6 | 0 | 1 | 0.23 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 18 | 2 | 13 | 7 | 8 | 3 | 9 | 5 | 6 | 1 | 1 | 0 | 2 |
3,359 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitEncoder | from torch import nn
from ...modeling_outputs import BaseModelOutputWithNoAttention, BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention, ModelOutput
class LevitEncoder(nn.Module):
"""
LeViT Encoder consisting of multiple `LevitStage` stages.
"""
def __init__(self, config):
... |
class LevitEncoder(nn.Module):
'''
LeViT Encoder consisting of multiple `LevitStage` stages.
'''
def __init__(self, config):
pass
def forward(self, hidden_state, output_hidden_states=False, return_dict=True):
pass | 3 | 1 | 19 | 3 | 17 | 0 | 4 | 0.09 | 1 | 5 | 2 | 0 | 2 | 2 | 2 | 12 | 44 | 7 | 34 | 10 | 31 | 3 | 23 | 10 | 20 | 6 | 1 | 2 | 8 |
3,360 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitForImageClassification | from ...utils import auto_docstring, logging
from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithNoAttention, BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention, ModelOutput
import torch
@auto_docstring(custom_intro='\n Levit Model with an image classifi... | @auto_docstring(custom_intro='\n Levit Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n ImageNet.\n ')
class LevitForImageClassification(LevitPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, pixel_... | 5 | 1 | 34 | 4 | 26 | 4 | 7 | 0.13 | 1 | 6 | 3 | 0 | 2 | 4 | 2 | 3 | 76 | 8 | 60 | 20 | 44 | 8 | 34 | 13 | 31 | 12 | 2 | 3 | 14 |
3,361 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitForImageClassificationWithTeacher | from typing import Optional, Union
import torch
from ...utils import auto_docstring, logging
@auto_docstring(custom_intro='\n LeViT Model transformer with image classification heads on top (a linear layer on top of the final hidden state and\n a linear layer on top of the final hidden state of the distillation t... | @auto_docstring(custom_intro='\n LeViT Model transformer with image classification heads on top (a linear layer on top of the final hidden state and\n a linear layer on top of the final hidden state of the distillation token) e.g. for ImageNet. .. warning::\n This model supports inference-only. Fine-tun... | 5 | 0 | 23 | 3 | 19 | 1 | 3 | 0.04 | 1 | 5 | 3 | 0 | 2 | 5 | 2 | 3 | 54 | 7 | 45 | 19 | 30 | 2 | 20 | 13 | 17 | 3 | 2 | 1 | 6 |
3,362 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitMLPLayer | from torch import nn
class LevitMLPLayer(nn.Module):
"""
MLP Layer with `2X` expansion in contrast to ViT with `4X`.
"""
def __init__(self, input_dim, hidden_dim):
super().__init__()
self.linear_up = MLPLayerWithBN(input_dim, hidden_dim)
self.activation = nn.Hardswish()
... |
class LevitMLPLayer(nn.Module):
'''
MLP Layer with `2X` expansion in contrast to ViT with `4X`.
'''
def __init__(self, input_dim, hidden_dim):
pass
def forward(self, hidden_state):
pass | 3 | 1 | 5 | 0 | 5 | 0 | 1 | 0.27 | 1 | 2 | 1 | 0 | 2 | 3 | 2 | 12 | 16 | 2 | 11 | 6 | 8 | 3 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
3,363 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitModel | from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithNoAttention, BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention, ModelOutput
from ...utils import auto_docstring, logging
import torch
@auto_docstring
class LevitModel(LevitPreTrainedModel):
def __ini... | @auto_docstring
class LevitModel(LevitPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, pixel_values: Optional[torch.FloatTensor]=None, output_hidden_states: Optional[bool]=None, return_dict: Optional[bool]=None) -> Union[tuple, BaseModelOutputWithPoolingAndNoAtte... | 5 | 0 | 21 | 3 | 17 | 1 | 3 | 0.05 | 1 | 6 | 3 | 0 | 2 | 3 | 2 | 3 | 51 | 7 | 42 | 16 | 26 | 2 | 19 | 10 | 16 | 5 | 2 | 1 | 6 |
3,364 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitPatchEmbeddings | from torch import nn
class LevitPatchEmbeddings(nn.Module):
"""
LeViT patch embeddings, for final embeddings to be passed to transformer blocks. It consists of multiple
`LevitConvEmbeddings`.
"""
def __init__(self, config):
super().__init__()
self.embedding_layer_1 = LevitConvEmbed... |
class LevitPatchEmbeddings(nn.Module):
'''
LeViT patch embeddings, for final embeddings to be passed to transformer blocks. It consists of multiple
`LevitConvEmbeddings`.
'''
def __init__(self, config):
pass
def forward(self, pixel_values):
pass | 3 | 1 | 18 | 2 | 16 | 0 | 2 | 0.12 | 1 | 3 | 1 | 0 | 2 | 8 | 2 | 12 | 42 | 5 | 33 | 13 | 30 | 4 | 23 | 13 | 20 | 2 | 1 | 1 | 3 |
3,365 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitPreTrainedModel | from ...utils import auto_docstring, logging
from ...modeling_utils import PreTrainedModel
from .configuration_levit import LevitConfig
from torch import nn
@auto_docstring
class LevitPreTrainedModel(PreTrainedModel):
config: LevitConfig
base_model_prefix = 'levit'
main_input_name = 'pixel_values'
_no_... | @auto_docstring
class LevitPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 11 | 0 | 8 | 3 | 4 | 0.54 | 1 | 0 | 0 | 3 | 1 | 0 | 1 | 1 | 22 | 2 | 13 | 6 | 11 | 7 | 12 | 6 | 10 | 4 | 1 | 2 | 4 |
3,366 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitResidualLayer | import torch
from torch import nn
class LevitResidualLayer(nn.Module):
"""
Residual Block for LeViT
"""
def __init__(self, module, drop_rate):
super().__init__()
self.module = module
self.drop_rate = drop_rate
def forward(self, hidden_state):
if self.training and s... |
class LevitResidualLayer(nn.Module):
'''
Residual Block for LeViT
'''
def __init__(self, module, drop_rate):
pass
def forward(self, hidden_state):
pass | 3 | 1 | 7 | 0 | 7 | 0 | 2 | 0.21 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 19 | 2 | 14 | 6 | 11 | 3 | 13 | 6 | 10 | 2 | 1 | 1 | 3 |
3,367 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitStage | from torch import nn
class LevitStage(nn.Module):
"""
LeViT Stage consisting of `LevitMLPLayer` and `LevitAttention` layers.
"""
def __init__(self, config, idx, hidden_sizes, key_dim, depths, num_attention_heads, attention_ratio, mlp_ratio, down_ops, resolution_in):
super().__init__()
... |
class LevitStage(nn.Module):
'''
LeViT Stage consisting of `LevitMLPLayer` and `LevitAttention` layers.
'''
def __init__(self, config, idx, hidden_sizes, key_dim, depths, num_attention_heads, attention_ratio, mlp_ratio, down_ops, resolution_in):
pass
def get_resolution(self):
pass... | 4 | 1 | 20 | 1 | 19 | 0 | 3 | 0.07 | 1 | 6 | 4 | 0 | 3 | 4 | 3 | 13 | 67 | 5 | 58 | 23 | 42 | 4 | 25 | 11 | 21 | 5 | 1 | 2 | 8 |
3,368 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.LevitSubsample | from torch import nn
class LevitSubsample(nn.Module):
def __init__(self, stride, resolution):
super().__init__()
self.stride = stride
self.resolution = resolution
def forward(self, hidden_state):
batch_size, _, channels = hidden_state.shape
hidden_state = hidden_state.... |
class LevitSubsample(nn.Module):
def __init__(self, stride, resolution):
pass
def forward(self, hidden_state):
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 12 | 1 | 11 | 6 | 8 | 0 | 9 | 6 | 6 | 1 | 1 | 0 | 2 |
3,369 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/levit/modeling_levit.py | transformers.models.levit.modeling_levit.MLPLayerWithBN | from torch import nn
class MLPLayerWithBN(nn.Module):
def __init__(self, input_dim, output_dim, bn_weight_init=1):
super().__init__()
self.linear = nn.Linear(in_features=input_dim, out_features=output_dim, bias=False)
self.batch_norm = nn.BatchNorm1d(output_dim)
def forward(self, hidd... |
class MLPLayerWithBN(nn.Module):
def __init__(self, input_dim, output_dim, bn_weight_init=1):
pass
def forward(self, hidden_state):
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,370 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/configuration_lilt.py | transformers.models.lilt.configuration_lilt.LiltConfig | from ...configuration_utils import PretrainedConfig
class LiltConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`LiltModel`]. It is used to instantiate a LiLT
model according to the specified arguments, defining the model architecture. Instantiating a configurat... |
class LiltConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`LiltModel`]. It is used to instantiate a LiLT
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar confi... | 2 | 1 | 39 | 1 | 38 | 0 | 1 | 1.45 | 1 | 1 | 0 | 0 | 1 | 16 | 1 | 1 | 105 | 7 | 40 | 39 | 18 | 58 | 20 | 19 | 18 | 1 | 1 | 0 | 1 |
3,371 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltAttention | from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
import torch
from typing import Optional, Union
from torch import nn
class LiltAttention(nn.Module):
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super().__init__()
... |
class LiltAttention(nn.Module):
def __init__(self, config, position_embedding_type=None, layer_idx=None):
pass
def prune_heads(self, heads):
pass
def forward(self, hidden_states: torch.Tensor, layout_inputs: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optio... | 4 | 0 | 15 | 1 | 14 | 1 | 1 | 0.1 | 1 | 6 | 2 | 0 | 3 | 4 | 3 | 13 | 50 | 5 | 42 | 21 | 31 | 4 | 27 | 14 | 23 | 2 | 1 | 1 | 4 |
3,372 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltClassificationHead | from torch import nn
import torch
class LiltClassificationHead(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_dropout = config.classifier_dropout if... |
class LiltClassificationHead(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 |
3,373 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltEncoder | import torch
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
from typing import Optional, Union
from torch import nn
class LiltEncoder(nn.Module):
def __init__(self, config):
super().__init__()
... |
class LiltEncoder(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, layout_inputs: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=False, output_hidden_states: Opti... | 3 | 0 | 33 | 4 | 30 | 0 | 6 | 0.02 | 1 | 8 | 2 | 0 | 2 | 3 | 2 | 12 | 69 | 8 | 60 | 20 | 48 | 1 | 25 | 11 | 22 | 10 | 1 | 2 | 11 |
3,374 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltForQuestionAnswering | import torch
from torch import nn
from ...utils import auto_docstring, logging
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
from typing import Optional, Union
from torch.nn import BCEWithLogitsLoss, CrossEntrop... | @auto_docstring
class LiltForQuestionAnswering(LiltPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, bbox: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[torch... | 5 | 1 | 55 | 9 | 31 | 15 | 4 | 0.48 | 1 | 5 | 2 | 0 | 2 | 3 | 2 | 3 | 115 | 19 | 65 | 31 | 46 | 31 | 32 | 16 | 29 | 7 | 2 | 2 | 8 |
3,375 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltForSequenceClassification | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from typing import Optional, Union
from ...utils import auto_docstring, logging
import torch
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
@auto... | @auto_docstring(custom_intro='\n LiLT 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 ')
class LiltForSequenceClassification(LiltPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
... | 5 | 1 | 52 | 7 | 34 | 12 | 7 | 0.34 | 1 | 7 | 3 | 0 | 2 | 4 | 2 | 3 | 109 | 15 | 70 | 27 | 52 | 24 | 34 | 13 | 31 | 12 | 2 | 3 | 13 |
3,376 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltForTokenClassification | from typing import Optional, Union
from ...utils import auto_docstring, logging
import torch
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from t... | @auto_docstring
class LiltForTokenClassification(LiltPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, bbox: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[tor... | 5 | 1 | 45 | 8 | 27 | 10 | 4 | 0.37 | 1 | 5 | 2 | 0 | 2 | 4 | 2 | 3 | 94 | 16 | 57 | 28 | 39 | 21 | 24 | 14 | 21 | 5 | 2 | 1 | 7 |
3,377 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltIntermediate | import torch
from ...activations import ACT2FN
from torch import nn
class LiltIntermediate(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_ac... |
class LiltIntermediate(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,378 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltLayer | from typing import Optional, Union
from ...modeling_layers import GradientCheckpointingLayer
import torch
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
class LiltLayer(GradientCheckpointingLayer):
def __init__(self, config, layer_idx=None):
su... |
class LiltLayer(GradientCheckpointingLayer):
def __init__(self, config, layer_idx=None):
pass
def forward(self, hidden_states: torch.Tensor, layout_inputs: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=Fa... | 5 | 0 | 13 | 1 | 12 | 0 | 1 | 0.04 | 1 | 6 | 3 | 0 | 4 | 7 | 4 | 14 | 58 | 7 | 50 | 31 | 38 | 2 | 33 | 24 | 28 | 1 | 1 | 0 | 4 |
3,379 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltLayoutEmbeddings | import torch
from torch import nn
class LiltLayoutEmbeddings(nn.Module):
def __init__(self, config):
super().__init__()
self.x_position_embeddings = nn.Embedding(config.max_2d_position_embeddings, config.hidden_size // 6)
self.y_position_embeddings = nn.Embedding(config.max_2d_position_emb... |
class LiltLayoutEmbeddings(nn.Module):
def __init__(self, config):
pass
def forward(self, bbox=None, position_ids=None):
pass | 3 | 0 | 26 | 3 | 22 | 1 | 2 | 0.04 | 1 | 2 | 0 | 0 | 2 | 9 | 2 | 12 | 54 | 7 | 45 | 21 | 42 | 2 | 29 | 20 | 26 | 2 | 1 | 1 | 3 |
3,380 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltModel | from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
from typing import Optional, Union
from ...utils import auto_docstring, logging
import torch
@auto_docstring
class LiltModel(LiltPreTrainedModel):
def __init__... | @auto_docstring
class LiltModel(LiltPreTrainedModel):
def __init__(self, config, add_pooling_layer=True):
'''
add_pooling_layer (bool, *optional*, defaults to `True`):
Whether to add a pooling layer
'''
pass
def get_input_embeddings(self):
pass
def set_... | 8 | 3 | 27 | 4 | 17 | 6 | 4 | 0.33 | 1 | 9 | 5 | 0 | 5 | 5 | 5 | 6 | 140 | 26 | 86 | 36 | 66 | 28 | 48 | 23 | 42 | 14 | 2 | 2 | 20 |
3,381 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltOutput | import torch
from torch import nn
class LiltOutput(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 LiltOutput(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,382 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltPooler | import torch
from torch import nn
class LiltPooler(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 LiltPooler(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,383 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltPreTrainedModel | from torch import nn
from ...utils import auto_docstring, logging
from ...modeling_utils import PreTrainedModel
from .configuration_lilt import LiltConfig
@auto_docstring
class LiltPreTrainedModel(PreTrainedModel):
config: LiltConfig
base_model_prefix = 'lilt'
supports_gradient_checkpointing = True
_no... | @auto_docstring
class LiltPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 15 | 0 | 12 | 3 | 6 | 0.47 | 1 | 0 | 0 | 4 | 1 | 0 | 1 | 1 | 27 | 2 | 17 | 6 | 15 | 8 | 15 | 6 | 13 | 6 | 1 | 2 | 6 |
3,384 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltSelfAttention | from torch import nn
import torch
import math
class LiltSelfAttention(nn.Module):
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super().__init__()
if config.hidden_size % config.num_attention_heads != 0 and (not hasattr(config, 'embedding_size')):
raise Valu... |
class LiltSelfAttention(nn.Module):
def __init__(self, config, position_embedding_type=None, layer_idx=None):
pass
def transpose_for_scores(self, x, r=1):
pass
def forward(self, hidden_states, layout_inputs, attention_mask=None, head_mask=None, output_attentions=False):
pass | 4 | 0 | 44 | 8 | 32 | 4 | 4 | 0.11 | 1 | 3 | 0 | 0 | 3 | 14 | 3 | 13 | 135 | 27 | 98 | 51 | 87 | 11 | 73 | 44 | 69 | 9 | 1 | 2 | 13 |
3,385 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltSelfOutput | import torch
from torch import nn
class LiltSelfOutput(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 LiltSelfOutput(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,386 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/lilt/modeling_lilt.py | transformers.models.lilt.modeling_lilt.LiltTextEmbeddings | import torch
from torch import nn
class LiltTextEmbeddings(nn.Module):
def __init__(self, config):
super().__init__()
self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=config.pad_token_id)
self.position_embeddings = nn.Embedding(config.max_position_embe... |
class LiltTextEmbeddings(nn.Module):
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_from_input_ids(self, input_ids, padding_idx):
'''
Args:
Replace non-pa... | 5 | 2 | 21 | 2 | 14 | 5 | 3 | 0.33 | 1 | 1 | 0 | 0 | 4 | 7 | 4 | 14 | 87 | 11 | 57 | 27 | 46 | 19 | 41 | 21 | 36 | 7 | 1 | 2 | 10 |
3,387 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/configuration_llama.py | transformers.models.llama.configuration_llama.LlamaConfig | from ...modeling_rope_utils import rope_config_validation
from ...configuration_utils import PretrainedConfig
class LlamaConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`LlamaModel`]. It is used to instantiate an LLaMA
model according to the specified argument... |
class LlamaConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`LlamaModel`]. It is used to instantiate an LLaMA
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar c... | 2 | 1 | 62 | 3 | 56 | 3 | 4 | 1.63 | 1 | 1 | 0 | 1 | 1 | 18 | 1 | 1 | 191 | 12 | 68 | 48 | 41 | 111 | 29 | 23 | 27 | 4 | 1 | 1 | 4 |
3,388 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/convert_llama_weights_to_hf.py | transformers.models.llama.convert_llama_weights_to_hf.Llama3Converter | from transformers.convert_slow_tokenizer import TikTokenConverter
from tokenizers import AddedToken, processors
from transformers import GenerationConfig, LlamaConfig, LlamaForCausalLM, LlamaTokenizer, PreTrainedTokenizerFast
class Llama3Converter(TikTokenConverter):
def __init__(self, vocab_file, special_tokens=... |
class Llama3Converter(TikTokenConverter):
def __init__(self, vocab_file, special_tokens=None, instruct=False, llama_version='3.2', **kwargs):
pass
def update_post_processor(self, tokenizer):
pass | 3 | 0 | 26 | 2 | 21 | 3 | 3 | 0.14 | 1 | 3 | 0 | 0 | 2 | 1 | 2 | 6 | 54 | 5 | 43 | 10 | 39 | 6 | 18 | 10 | 14 | 5 | 1 | 2 | 6 |
3,389 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaAttention | from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...cache_utils import Cache, DynamicCache
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from ...processing_utils import Unpack
from typing import Callable, Optional, Union
import torch
from ...utils.deprecat... |
class LlamaAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, config: LlamaConfig, layer_idx: int):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, posit... | 4 | 1 | 35 | 4 | 31 | 1 | 3 | 0.03 | 1 | 6 | 3 | 7 | 2 | 11 | 2 | 12 | 74 | 9 | 63 | 31 | 52 | 2 | 34 | 23 | 31 | 5 | 1 | 2 | 6 |
3,390 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaDecoderLayer | from .configuration_llama import LlamaConfig
from ...processing_utils import Unpack
from ...modeling_layers import GenericForQuestionAnswering, GenericForSequenceClassification, GenericForTokenClassification, GradientCheckpointingLayer
import torch
from typing import Callable, Optional, Union
from ...cache_utils import... |
class LlamaDecoderLayer(GradientCheckpointingLayer):
def __init__(self, config: LlamaConfig, layer_idx: int):
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... | 4 | 0 | 25 | 4 | 21 | 2 | 2 | 0.07 | 1 | 10 | 6 | 9 | 2 | 5 | 2 | 12 | 52 | 8 | 42 | 22 | 28 | 3 | 21 | 11 | 18 | 2 | 1 | 1 | 3 |
3,391 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaForCausalLM | from torch import nn
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...cache_utils import Cache, DynamicCache
from ...generation import GenerationMixin
from ...processing_utils import Unpack
from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
from typ... | @auto_docstring
class LlamaForCausalLM(LlamaPreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
@can_return_tuple
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.Tensor]=None, position_ids: Optional[torch.LongTensor]=N... | 6 | 1 | 14 | 2 | 9 | 4 | 2 | 0.38 | 2 | 9 | 4 | 10 | 8 | 3 | 8 | 9 | 123 | 21 | 74 | 36 | 47 | 28 | 36 | 20 | 27 | 8 | 2 | 1 | 15 |
3,392 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaForQuestionAnswering | from ...modeling_layers import GenericForQuestionAnswering, GenericForSequenceClassification, GenericForTokenClassification, GradientCheckpointingLayer
class LlamaForQuestionAnswering(GenericForQuestionAnswering, LlamaPreTrainedModel):
base_model_prefix = 'transformer' |
class LlamaForQuestionAnswering(GenericForQuestionAnswering, LlamaPreTrainedModel):
pass | 1 | 0 | 18 | 2 | 13 | 3 | 2 | 0.22 | 1 | 5 | 3 | 3 | 4 | 2 | 4 | 5 | 78 | 11 | 55 | 28 | 36 | 12 | 26 | 14 | 21 | 5 | 2 | 1 | 8 |
3,393 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaForSequenceClassification | from ...modeling_layers import GenericForQuestionAnswering, GenericForSequenceClassification, GenericForTokenClassification, GradientCheckpointingLayer
class LlamaForSequenceClassification(GenericForSequenceClassification, LlamaPreTrainedModel):
... |
class LlamaForSequenceClassification(GenericForSequenceClassification, LlamaPreTrainedModel):
pass | 1 | 0 | 21 | 2 | 17 | 2 | 3 | 0.11 | 1 | 7 | 3 | 6 | 4 | 3 | 4 | 5 | 90 | 11 | 71 | 31 | 53 | 8 | 36 | 18 | 31 | 9 | 2 | 1 | 12 |
3,394 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaForTokenClassification | from ...modeling_layers import GenericForQuestionAnswering, GenericForSequenceClassification, GenericForTokenClassification, GradientCheckpointingLayer
class LlamaForTokenClassification(GenericForTokenClassification, LlamaPreTrainedModel):
... |
class LlamaForTokenClassification(GenericForTokenClassification, LlamaPreTrainedModel):
pass | 1 | 0 | 17 | 1 | 14 | 2 | 3 | 0.11 | 1 | 5 | 2 | 6 | 4 | 4 | 4 | 5 | 79 | 8 | 64 | 28 | 41 | 7 | 29 | 15 | 24 | 5 | 2 | 1 | 10 |
3,395 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaMLP | from torch import nn
from ...activations import ACT2FN
class LlamaMLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.hidden_size = config.hidden_size
self.intermediate_size = config.intermediate_size
self.gate_proj = nn.Linear(self.hidd... |
class LlamaMLP(nn.Module):
def __init__(self, config):
pass
def forward(self, x):
pass | 3 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 1 | 1 | 0 | 7 | 2 | 7 | 2 | 12 | 14 | 1 | 13 | 11 | 10 | 0 | 13 | 11 | 10 | 1 | 1 | 0 | 2 |
3,396 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaModel | from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from torch import nn
from typing import Callable, Optional, Union
from ...processing_utils import Unpack
from ...utils.generic import check_model_inputs
impo... | @auto_docstring
class LlamaModel(LlamaPreTrainedModel):
def __init__(self, config: LlamaConfig):
pass
@check_model_inputs
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.Tensor]=None, position_ids: Optional[torch.LongTensor]=None, pas... | 6 | 0 | 40 | 5 | 30 | 6 | 6 | 0.22 | 1 | 16 | 10 | 13 | 5 | 7 | 6 | 7 | 257 | 34 | 184 | 65 | 146 | 40 | 89 | 34 | 82 | 21 | 2 | 2 | 37 |
3,397 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaPreTrainedModel | from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_llama import LlamaConfig
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
@auto_docstring
class LlamaPreTrainedModel(PreTrainedModel):
config: LlamaConfig
base_model_prefix = 'model'
... | @auto_docstring
class LlamaPreTrainedModel(PreTrainedModel):
pass | 2 | 0 | 10 | 0 | 10 | 0 | 5 | 0 | 1 | 0 | 0 | 9 | 1 | 0 | 1 | 1 | 24 | 1 | 23 | 15 | 21 | 0 | 22 | 15 | 20 | 5 | 1 | 2 | 5 |
3,398 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaRMSNorm | from torch import nn
import torch
from ...integrations import use_kernel_forward_from_hub
@use_kernel_forward_from_hub('RMSNorm')
class LlamaRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
"""
LlamaRMSNorm is equivalent to T5LayerNorm
"""
super().__init__()
... | @use_kernel_forward_from_hub('RMSNorm')
class LlamaRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
'''
LlamaRMSNorm is equivalent to T5LayerNorm
'''
pass
def forward(self, hidden_states):
pass
def extra_repr(self):
pass | 5 | 1 | 5 | 0 | 4 | 1 | 1 | 0.23 | 1 | 2 | 0 | 2 | 3 | 2 | 3 | 13 | 18 | 2 | 13 | 8 | 9 | 3 | 13 | 8 | 9 | 1 | 1 | 0 | 3 |
3,399 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/llama/modeling_llama.py | transformers.models.llama.modeling_llama.LlamaRotaryEmbedding | from .configuration_llama import LlamaConfig
from torch import nn
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
import torch
class LlamaRotaryEmbedding(nn.Module):
inv_freq: torch.Tensor
def __init__(self, config: LlamaConfig, device=None):
super().__init__()
if h... |
class LlamaRotaryEmbedding(nn.Module):
def __init__(self, config: LlamaConfig, device=None):
pass
@torch.no_grad()
@dynamic_rope_update
def forward(self, x, position_ids):
pass | 5 | 0 | 18 | 2 | 13 | 5 | 3 | 0.35 | 1 | 4 | 1 | 4 | 3 | 7 | 3 | 13 | 59 | 8 | 40 | 21 | 35 | 14 | 38 | 20 | 34 | 3 | 1 | 1 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.