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,000 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/configuration_ibert.py | transformers.models.ibert.configuration_ibert.IBertConfig | from ...configuration_utils import PretrainedConfig
class IBertConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`IBertModel`]. It is used to instantiate a I-BERT
model according to the specified arguments, defining the model architecture. Instantiating a config... |
class IBertConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`IBertModel`]. It is used to instantiate a I-BERT
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar c... | 2 | 1 | 39 | 1 | 38 | 0 | 1 | 1.25 | 1 | 1 | 0 | 0 | 1 | 15 | 1 | 1 | 95 | 5 | 40 | 39 | 17 | 50 | 19 | 18 | 17 | 1 | 1 | 0 | 1 |
3,001 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/configuration_ibert.py | transformers.models.ibert.configuration_ibert.IBertOnnxConfig | from ...onnx import OnnxConfig
from collections.abc import Mapping
from collections import OrderedDict
class IBertOnnxConfig(OnnxConfig):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
if self.task == 'multiple-choice':
dynamic_axis = {0: 'batch', 1: 'choice', 2: 'sequence'... |
class IBertOnnxConfig(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 | 1 | 13 | 0 | 13 | 4 | 10 | 0 | 6 | 3 | 4 | 2 | 1 | 1 | 2 |
3,002 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertAttention | from ...pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer
from torch import nn
class IBertAttention(nn.Module):
def __init__(self, config):
super().__init__()
self.quant_mode = config.quant_mode
self.self = IBertSelfAttention(config)
self.output = IBertSelfO... |
class IBertAttention(nn.Module):
def __init__(self, config):
pass
def prune_heads(self, heads):
pass
def forward(self, hidden_states, hidden_states_scaling_factor, attention_mask=None, head_mask=None, output_attentions=False):
pass | 4 | 0 | 15 | 1 | 13 | 1 | 1 | 0.07 | 1 | 4 | 2 | 0 | 3 | 4 | 3 | 13 | 47 | 4 | 41 | 20 | 30 | 3 | 24 | 13 | 20 | 2 | 1 | 1 | 4 |
3,003 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertClassificationHead | from torch import nn
import torch
class IBertClassificationHead(nn.Module):
"""Head for sentence-level classification tasks."""
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.dropout = nn.Dropout(config.hidden_dropout_... |
class IBertClassificationHead(nn.Module):
'''Head for sentence-level classification tasks.'''
def __init__(self, config):
pass
def forward(self, features, **kwargs):
pass | 3 | 1 | 7 | 0 | 7 | 1 | 1 | 0.14 | 1 | 1 | 0 | 0 | 2 | 3 | 2 | 12 | 17 | 2 | 14 | 7 | 11 | 2 | 14 | 7 | 11 | 1 | 1 | 0 | 2 |
3,004 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertEmbeddings | from torch import nn
import torch
from .quant_modules import IntGELU, IntLayerNorm, IntSoftmax, QuantAct, QuantEmbedding, QuantLinear
class IBertEmbeddings(nn.Module):
"""
Same as BertEmbeddings with a tiny tweak for positional embeddings indexing.
"""
def __init__(self, config):
super().__ini... |
class IBertEmbeddings(nn.Module):
'''
Same as BertEmbeddings with a tiny tweak for positional embeddings indexing.
'''
def __init__(self, config):
pass
def forward(self, input_ids=None, token_type_ids=None, position_ids=None, inputs_embeds=None, past_key_values_length=0):
pass
... | 4 | 2 | 38 | 5 | 29 | 4 | 3 | 0.17 | 1 | 4 | 3 | 0 | 3 | 16 | 3 | 13 | 120 | 17 | 88 | 30 | 82 | 15 | 47 | 28 | 43 | 7 | 1 | 2 | 9 |
3,005 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertEncoder | from torch import nn
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
class IBertEncoder(nn.Module):
def __init__(self, c... |
class IBertEncoder(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states, hidden_states_scaling_factor, attention_mask=None, head_mask=None, output_attentions=False, output_hidden_states=False, return_dict=True):
pass | 3 | 0 | 30 | 3 | 27 | 1 | 5 | 0.04 | 1 | 6 | 2 | 0 | 2 | 3 | 2 | 12 | 62 | 7 | 55 | 22 | 43 | 2 | 24 | 13 | 21 | 9 | 1 | 2 | 10 |
3,006 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertForMaskedLM | import torch
from ...utils import auto_docstring, logging
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, Se... | @auto_docstring
class IBertForMaskedLM(IBertPreTrainedModel):
def __init__(self, config):
pass
def get_output_embeddings(self):
pass
def set_output_embeddings(self, new_embeddings):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attentio... | 7 | 1 | 16 | 2 | 13 | 2 | 2 | 0.15 | 1 | 5 | 3 | 0 | 4 | 2 | 4 | 6 | 78 | 10 | 59 | 27 | 35 | 9 | 25 | 14 | 20 | 5 | 2 | 1 | 8 |
3,007 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertForMultipleChoice | import torch
from ...utils import auto_docstring, logging
from typing import Optional, Union
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutpu... | @auto_docstring
class IBertForMultipleChoice(IBertPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, labels: Optional[torc... | 5 | 1 | 37 | 4 | 29 | 4 | 6 | 0.11 | 1 | 4 | 2 | 0 | 2 | 3 | 2 | 4 | 81 | 9 | 65 | 32 | 44 | 7 | 28 | 19 | 25 | 11 | 2 | 1 | 12 |
3,008 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertForQuestionAnswering | from typing import Optional, Union
from ...utils import auto_docstring, logging
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutpu... | @auto_docstring
class IBertForQuestionAnswering(IBertPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, position_ids: Opti... | 5 | 0 | 41 | 5 | 30 | 7 | 4 | 0.19 | 1 | 4 | 2 | 0 | 2 | 3 | 2 | 4 | 90 | 10 | 67 | 30 | 45 | 13 | 32 | 16 | 29 | 7 | 2 | 2 | 8 |
3,009 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertForSequenceClassification | import torch
from typing import Optional, Union
from ...utils import auto_docstring, logging
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenCl... | @auto_docstring(custom_intro='\n I-BERT 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 IBertForSequenceClassification(IBertPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
... | 5 | 1 | 38 | 3 | 32 | 4 | 7 | 0.1 | 1 | 6 | 3 | 0 | 2 | 3 | 2 | 4 | 84 | 7 | 70 | 25 | 49 | 7 | 32 | 12 | 29 | 12 | 2 | 3 | 13 |
3,010 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertForTokenClassification | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
from ...util... | @auto_docstring
class IBertForTokenClassification(IBertPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, position_ids: Op... | 5 | 1 | 31 | 4 | 24 | 3 | 3 | 0.09 | 1 | 4 | 2 | 0 | 2 | 4 | 2 | 4 | 69 | 9 | 55 | 26 | 34 | 5 | 22 | 13 | 19 | 5 | 2 | 1 | 6 |
3,011 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertIntermediate | from .quant_modules import IntGELU, IntLayerNorm, IntSoftmax, QuantAct, QuantEmbedding, QuantLinear
from torch import nn
class IBertIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.quant_mode = config.quant_mode
self.act_bit = 8
self.weight_bit = 8
... |
class IBertIntermediate(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states, hidden_states_scaling_factor):
pass | 3 | 0 | 15 | 1 | 14 | 1 | 2 | 0.03 | 1 | 5 | 3 | 0 | 2 | 7 | 2 | 12 | 32 | 2 | 29 | 10 | 26 | 1 | 17 | 10 | 14 | 2 | 1 | 1 | 3 |
3,012 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertLMHead | import torch
from ...activations import gelu
from torch import nn
class IBertLMHead(nn.Module):
"""I-BERT Head for masked language modeling."""
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.layer_norm = nn.LayerNorm(c... |
class IBertLMHead(nn.Module):
'''I-BERT Head for masked language modeling.'''
def __init__(self, config):
pass
def forward(self, features, **kwargs):
pass
def _tie_weights(self) -> None:
pass | 4 | 1 | 8 | 1 | 6 | 1 | 1 | 0.21 | 1 | 1 | 0 | 0 | 3 | 4 | 3 | 13 | 29 | 6 | 19 | 9 | 15 | 4 | 18 | 9 | 14 | 2 | 1 | 1 | 4 |
3,013 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertLayer | from .quant_modules import IntGELU, IntLayerNorm, IntSoftmax, QuantAct, QuantEmbedding, QuantLinear
from torch import nn
class IBertLayer(nn.Module):
def __init__(self, config):
super().__init__()
self.quant_mode = config.quant_mode
self.act_bit = 8
self.seq_len_dim = 1
sel... |
class IBertLayer(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states, hidden_states_scaling_factor, attention_mask=None, head_mask=None, output_attentions=False):
pass
def feed_forward_chunk(self, attention_output, attention_output_scaling_factor):
pass | 4 | 0 | 18 | 2 | 16 | 0 | 1 | 0.02 | 1 | 5 | 4 | 0 | 3 | 8 | 3 | 13 | 56 | 8 | 48 | 26 | 37 | 1 | 25 | 19 | 21 | 1 | 1 | 0 | 3 |
3,014 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertModel | from ...utils import auto_docstring, logging
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
import torch
from typing import O... | @auto_docstring
class IBertModel(IBertPreTrainedModel):
'''
The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added between the self-attention layers, following the architecture described in [Attention is
all you need](https:/... | 8 | 3 | 20 | 2 | 15 | 2 | 4 | 0.22 | 1 | 8 | 4 | 0 | 5 | 5 | 5 | 7 | 119 | 18 | 83 | 32 | 60 | 18 | 41 | 20 | 35 | 12 | 2 | 1 | 18 |
3,015 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertOutput | from .quant_modules import IntGELU, IntLayerNorm, IntSoftmax, QuantAct, QuantEmbedding, QuantLinear
from torch import nn
class IBertOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.quant_mode = config.quant_mode
self.act_bit = 8
self.weight_bit = 8
sel... |
class IBertOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states, hidden_states_scaling_factor, input_tensor, input_tensor_scaling_factor):
pass | 3 | 0 | 22 | 1 | 21 | 0 | 1 | 0 | 1 | 4 | 3 | 0 | 2 | 11 | 2 | 12 | 45 | 3 | 42 | 14 | 39 | 0 | 21 | 14 | 18 | 1 | 1 | 0 | 2 |
3,016 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertPooler | from torch import nn
class IBertPooler(nn.Module):
def __init__(self, config):
super().__init__()
self.quant_mode = config.quant_mode
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.activation = nn.Tanh()
def forward(self, hidden_states):
first_toke... |
class IBertPooler(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 6 | 0 | 5 | 1 | 1 | 0.18 | 1 | 1 | 0 | 0 | 2 | 3 | 2 | 12 | 14 | 1 | 11 | 8 | 8 | 2 | 11 | 8 | 8 | 1 | 1 | 0 | 2 |
3,017 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertPreTrainedModel | from ...utils import auto_docstring, logging
from .configuration_ibert import IBertConfig
from .quant_modules import IntGELU, IntLayerNorm, IntSoftmax, QuantAct, QuantEmbedding, QuantLinear
from ...modeling_utils import PreTrainedModel
from torch import nn
@auto_docstring
class IBertPreTrainedModel(PreTrainedModel):
... | @auto_docstring
class IBertPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass
def resize_token_embeddings(self, new_num_tokens=None):
pass | 4 | 1 | 9 | 0 | 7 | 2 | 4 | 0.41 | 1 | 4 | 3 | 6 | 2 | 0 | 2 | 2 | 27 | 3 | 17 | 5 | 14 | 7 | 15 | 5 | 12 | 6 | 1 | 2 | 7 |
3,018 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertSelfAttention | from torch import nn
import torch
from .quant_modules import IntGELU, IntLayerNorm, IntSoftmax, QuantAct, QuantEmbedding, QuantLinear
import math
class IBertSelfAttention(nn.Module):
def __init__(self, config):
super().__init__()
if config.hidden_size % config.num_attention_heads != 0 and (not has... |
class IBertSelfAttention(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states, hidden_states_scaling_factor, attention_mask=None, head_mask=None, output_attentions=False):
pass | 3 | 0 | 46 | 6 | 36 | 4 | 4 | 0.11 | 1 | 6 | 3 | 0 | 3 | 17 | 3 | 13 | 140 | 19 | 109 | 44 | 98 | 12 | 61 | 37 | 57 | 7 | 1 | 1 | 11 |
3,019 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/modeling_ibert.py | transformers.models.ibert.modeling_ibert.IBertSelfOutput | from .quant_modules import IntGELU, IntLayerNorm, IntSoftmax, QuantAct, QuantEmbedding, QuantLinear
from torch import nn
class IBertSelfOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.quant_mode = config.quant_mode
self.act_bit = 8
self.weight_bit = 8
... |
class IBertSelfOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states, hidden_states_scaling_factor, input_tensor, input_tensor_scaling_factor):
pass | 3 | 0 | 22 | 1 | 21 | 0 | 1 | 0 | 1 | 4 | 3 | 0 | 2 | 11 | 2 | 12 | 45 | 3 | 42 | 14 | 39 | 0 | 21 | 14 | 18 | 1 | 1 | 0 | 2 |
3,020 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/quant_modules.py | transformers.models.ibert.quant_modules.FixedPointMul | import torch
from torch.autograd import Function
class FixedPointMul(Function):
"""
Function to perform fixed-point arithmetic that can match integer arithmetic on hardware.
Args:
pre_act (`torch.Tensor`):
Input tensor.
pre_act_scaling_factor (`torch.Tensor`):
Scali... |
class FixedPointMul(Function):
'''
Function to perform fixed-point arithmetic that can match integer arithmetic on hardware.
Args:
pre_act (`torch.Tensor`):
Input tensor.
pre_act_scaling_factor (`torch.Tensor`):
Scaling factor of the input tensor *pre_act*.
b... | 7 | 1 | 28 | 6 | 22 | 2 | 3 | 0.47 | 1 | 1 | 0 | 0 | 0 | 0 | 2 | 2 | 82 | 15 | 47 | 25 | 34 | 22 | 36 | 15 | 33 | 4 | 1 | 2 | 6 |
3,021 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/quant_modules.py | transformers.models.ibert.quant_modules.IntGELU | import torch
from torch import nn
class IntGELU(nn.Module):
"""
Quantized version of `torch.nn.GELU`. Adds quantization-specific arguments on top of `torch.nn.GELU`.
Args:
quant_mode (`bool`, *optional*, defaults to `False`):
Whether or not the layer is quantized.
force_dequant... |
class IntGELU(nn.Module):
'''
Quantized version of `torch.nn.GELU`. Adds quantization-specific arguments on top of `torch.nn.GELU`.
Args:
quant_mode (`bool`, *optional*, defaults to `False`):
Whether or not the layer is quantized.
force_dequant (`str`, *optional*, defaults to `"... | 4 | 1 | 14 | 3 | 10 | 1 | 2 | 0.34 | 1 | 2 | 1 | 0 | 3 | 5 | 3 | 13 | 55 | 14 | 32 | 17 | 28 | 11 | 32 | 17 | 28 | 3 | 1 | 1 | 6 |
3,022 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/quant_modules.py | transformers.models.ibert.quant_modules.IntLayerNorm | import torch
from torch import nn
class IntLayerNorm(nn.Module):
"""
Quantized version of `torch.nn.LayerNorm`. Adds quantization-specific arguments on top of `torch.nn.LayerNorm`.
Args:
output_bit (`int`, *optional*, defaults to `8`):
Bitwidth for the layer output activation.
... |
class IntLayerNorm(nn.Module):
'''
Quantized version of `torch.nn.LayerNorm`. Adds quantization-specific arguments on top of `torch.nn.LayerNorm`.
Args:
output_bit (`int`, *optional*, defaults to `8`):
Bitwidth for the layer output activation.
quant_mode (`bool`, *optional*, def... | 5 | 2 | 21 | 3 | 16 | 3 | 2 | 0.33 | 1 | 6 | 3 | 0 | 4 | 10 | 4 | 14 | 99 | 15 | 64 | 36 | 59 | 21 | 61 | 36 | 56 | 5 | 1 | 2 | 9 |
3,023 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/quant_modules.py | transformers.models.ibert.quant_modules.IntSoftmax | import torch
from torch import nn
class IntSoftmax(nn.Module):
"""
Quantized version of `torch.nn.Softmax`. Adds quantization-specific arguments on top of `torch.nn.Softmax`.
Args:
output_bit (`int`):
Bitwidth for the layer output activation.
quant_mode (`bool`, *optional*, def... |
class IntSoftmax(nn.Module):
'''
Quantized version of `torch.nn.Softmax`. Adds quantization-specific arguments on top of `torch.nn.Softmax`.
Args:
output_bit (`int`):
Bitwidth for the layer output activation.
quant_mode (`bool`, *optional*, defaults to `False`):
Whet... | 5 | 1 | 13 | 2 | 11 | 1 | 2 | 0.3 | 1 | 3 | 2 | 0 | 4 | 7 | 4 | 14 | 69 | 12 | 46 | 25 | 41 | 14 | 46 | 25 | 41 | 2 | 1 | 1 | 6 |
3,024 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/quant_modules.py | transformers.models.ibert.quant_modules.QuantAct | from torch import nn
import torch
class QuantAct(nn.Module):
"""
Quantizes the given activation.
Args:
activation_bit (`int`):
Bitwidth for the quantized activation.
act_range_momentum (`float`, *optional*, defaults to `0.95`):
Momentum for updating the activation q... |
class QuantAct(nn.Module):
'''
Quantizes the given activation.
Args:
activation_bit (`int`):
Bitwidth for the quantized activation.
act_range_momentum (`float`, *optional*, defaults to `0.95`):
Momentum for updating the activation quantization range.
per_chan... | 4 | 1 | 28 | 4 | 23 | 2 | 4 | 0.27 | 1 | 4 | 2 | 0 | 3 | 9 | 3 | 13 | 104 | 15 | 70 | 26 | 58 | 19 | 43 | 18 | 39 | 9 | 1 | 2 | 12 |
3,025 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/quant_modules.py | transformers.models.ibert.quant_modules.QuantEmbedding | import torch
from torch import nn
class QuantEmbedding(nn.Module):
"""
Quantized version of `torch.nn.Embedding`. Adds quantization-specific arguments on top of `torch.nn.Embedding`.
Args:
weight_bit (`int`, *optional*, defaults to `8`):
Bitwidth for the quantized weight.
momen... |
class QuantEmbedding(nn.Module):
'''
Quantized version of `torch.nn.Embedding`. Adds quantization-specific arguments on top of `torch.nn.Embedding`.
Args:
weight_bit (`int`, *optional*, defaults to `8`):
Bitwidth for the quantized weight.
momentum (`float`, *optional*, defaults ... | 3 | 1 | 34 | 3 | 31 | 0 | 2 | 0.16 | 1 | 2 | 1 | 0 | 2 | 15 | 2 | 12 | 81 | 8 | 63 | 36 | 47 | 10 | 29 | 23 | 26 | 2 | 1 | 1 | 3 |
3,026 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/quant_modules.py | transformers.models.ibert.quant_modules.QuantLinear | from torch import nn
import torch
class QuantLinear(nn.Module):
"""
Quantized version of `torch.nn.Linear`. Adds quantization-specific arguments on top of `torch.nn.Linear`.
Args:
weight_bit (`int`, *optional*, defaults to `8`):
Bitwidth for the quantized weight.
bias_bit (`int... |
class QuantLinear(nn.Module):
'''
Quantized version of `torch.nn.Linear`. Adds quantization-specific arguments on top of `torch.nn.Linear`.
Args:
weight_bit (`int`, *optional*, defaults to `8`):
Bitwidth for the quantized weight.
bias_bit (`int`, *optional*, defaults to `32`):
... | 4 | 1 | 20 | 3 | 17 | 0 | 2 | 0.25 | 1 | 2 | 1 | 0 | 3 | 13 | 3 | 13 | 78 | 13 | 52 | 26 | 46 | 13 | 41 | 24 | 37 | 4 | 1 | 1 | 7 |
3,027 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/quant_modules.py | transformers.models.ibert.quant_modules.SymmetricQuantFunction | import torch
from torch.autograd import Function
class SymmetricQuantFunction(Function):
"""
Class to quantize the given floating-point values using symmetric quantization with given range and bitwidth.
"""
@staticmethod
def forward(ctx, x, k, percentile_mode, scale):
"""
Args:
... |
class SymmetricQuantFunction(Function):
'''
Class to quantize the given floating-point values using symmetric quantization with given range and bitwidth.
'''
@staticmethod
def forward(ctx, x, k, percentile_mode, scale):
'''
Args:
x (`torch.Tensor`):
Float... | 5 | 2 | 18 | 2 | 8 | 8 | 2 | 0.95 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 43 | 6 | 19 | 9 | 14 | 18 | 15 | 7 | 12 | 3 | 1 | 1 | 4 |
3,028 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/quant_modules.py | transformers.models.ibert.quant_modules.floor_ste | import torch
from torch.autograd import Function
class floor_ste(Function):
"""
Straight-through Estimator(STE) for torch.floor()
"""
@staticmethod
def forward(ctx, x):
return torch.floor(x)
@staticmethod
def backward(ctx, grad_output):
return grad_output.clone() |
class floor_ste(Function):
'''
Straight-through Estimator(STE) for torch.floor()
'''
@staticmethod
def forward(ctx, x):
pass
@staticmethod
def backward(ctx, grad_output):
pass | 5 | 1 | 2 | 0 | 2 | 0 | 1 | 0.43 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 12 | 2 | 7 | 5 | 2 | 3 | 5 | 3 | 2 | 1 | 1 | 0 | 2 |
3,029 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ibert/quant_modules.py | transformers.models.ibert.quant_modules.round_ste | from torch.autograd import Function
import torch
class round_ste(Function):
"""
Straight-through Estimator(STE) for torch.round()
"""
@staticmethod
def forward(ctx, x):
return torch.round(x)
@staticmethod
def backward(ctx, grad_output):
return grad_output.clone() |
class round_ste(Function):
'''
Straight-through Estimator(STE) for torch.round()
'''
@staticmethod
def forward(ctx, x):
pass
@staticmethod
def backward(ctx, grad_output):
pass | 5 | 1 | 2 | 0 | 2 | 0 | 1 | 0.43 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 12 | 2 | 7 | 5 | 2 | 3 | 5 | 3 | 2 | 1 | 1 | 0 | 2 |
3,030 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/configuration_idefics.py | transformers.models.idefics.configuration_idefics.IdeficsConfig | from ...configuration_utils import PretrainedConfig
class IdeficsConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`IdeficsModel`]. It is used to instantiate an
Idefics model according to the specified arguments, defining the model architecture. Instantiating a ... |
class IdeficsConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`IdeficsModel`]. It is used to instantiate an
Idefics model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a sim... | 2 | 1 | 79 | 6 | 73 | 0 | 7 | 0.93 | 1 | 4 | 2 | 0 | 1 | 24 | 1 | 1 | 163 | 16 | 76 | 59 | 43 | 71 | 35 | 28 | 33 | 7 | 1 | 1 | 7 |
3,031 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/configuration_idefics.py | transformers.models.idefics.configuration_idefics.IdeficsPerceiverConfig | from ...configuration_utils import PretrainedConfig
class IdeficsPerceiverConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`IdeficsModel`]. It is used to instantiate an
Idefics model according to the specified arguments, defining the model architecture. Instant... |
class IdeficsPerceiverConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`IdeficsModel`]. It is used to instantiate an
Idefics model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yi... | 2 | 1 | 18 | 1 | 17 | 0 | 1 | 1.11 | 1 | 1 | 0 | 0 | 1 | 6 | 1 | 1 | 46 | 6 | 19 | 18 | 8 | 21 | 10 | 9 | 8 | 1 | 1 | 0 | 1 |
3,032 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/configuration_idefics.py | transformers.models.idefics.configuration_idefics.IdeficsVisionConfig | from ...configuration_utils import PretrainedConfig
class IdeficsVisionConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`IdeficsModel`]. It is used to instantiate an
Idefics model according to the specified arguments, defining the model architecture. Instantiat... |
class IdeficsVisionConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`IdeficsModel`]. It is used to instantiate an
Idefics model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield... | 2 | 1 | 30 | 1 | 29 | 0 | 1 | 1.03 | 1 | 1 | 0 | 0 | 1 | 12 | 1 | 1 | 75 | 6 | 34 | 31 | 17 | 35 | 17 | 16 | 15 | 1 | 1 | 0 | 1 |
3,033 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/image_processing_idefics.py | transformers.models.idefics.image_processing_idefics.IdeficsImageProcessor | from ...utils import TensorType, is_torch_available
from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import resize, to_channel_dimension_format
from ...image_utils import ChannelDimension, ImageInput, PILImageResampling, make_flat_list_of_images, to_numpy_array, valid_imag... |
class IdeficsImageProcessor(BaseImageProcessor):
'''
Constructs a Idefics image processor.
Args:
image_size (`int`, *optional*, defaults to 224):
Resize to image size
image_mean (`float` or `list[float]`, *optional*, defaults to `IDEFICS_STANDARD_MEAN`):
Mean to use ... | 3 | 2 | 48 | 6 | 26 | 17 | 5 | 0.94 | 1 | 9 | 2 | 0 | 2 | 4 | 2 | 22 | 118 | 15 | 53 | 27 | 32 | 50 | 33 | 10 | 29 | 9 | 3 | 2 | 10 |
3,034 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsAttention | from typing import Any, Callable, Optional, Union
import torch
import torch.nn.functional as F
from torch import nn
from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache, DynamicCache
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...modeling_utils im... |
class IdeficsAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, hidden_size: int, num_heads: int, dropout: float=0.0, is_cross_attention: bool=False, config: PretrainedConfig=None, qk_layer_norms: bool=False, layer_idx: Optional[int]=None):
pas... | 5 | 1 | 56 | 7 | 46 | 3 | 7 | 0.07 | 1 | 8 | 2 | 0 | 3 | 15 | 3 | 13 | 173 | 24 | 140 | 52 | 117 | 10 | 72 | 33 | 68 | 12 | 1 | 1 | 20 |
3,035 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsBaseModelOutputWithPast | from ...modeling_outputs import ModelOutput
from typing import Any, Callable, Optional, Union
from dataclasses import dataclass
import torch
import torch.nn.functional as F
from ...cache_utils import Cache, DynamicCache
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
@dataclass
@auto... | @dataclass
@auto_docstring(custom_intro="\n Base class for Idefics model's outputs that may also contain a past key/values (to speed up sequential decoding).\n ")
class IdeficsBaseModelOutputWithPast(ModelOutput):
'''
last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_si... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 4.83 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 42 | 7 | 6 | 6 | 5 | 29 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
3,036 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsCausalLMOutputWithPast | from typing import Any, Callable, Optional, Union
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...cache_utils import Cache, DynamicCache
import torch
import torch.nn.functional as F
from ...modeling_outputs import ModelOutput
from dataclasses import dataclass
@dataclass
@auto... | @dataclass
@auto_docstring(custom_intro='\n Base class for Idefics causal language model (or autoregressive) outputs.\n ')
class IdeficsCausalLMOutputWithPast(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Language modeling loss (for n... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.71 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 39 | 6 | 7 | 7 | 6 | 26 | 7 | 7 | 6 | 0 | 1 | 0 | 0 |
3,037 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsDecoderLayer | from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from .configuration_idefics import IdeficsConfig
from ...processing_utils import Unpack
from ...cache_utils import Cache, DynamicCache
import torch.nn.functional as F
from torch import nn
from typing import Any, Callable, Optional, Union... |
class IdeficsDecoderLayer(GradientCheckpointingLayer):
def __init__(self, config: IdeficsConfig, layer_idx: Optional[int]=None):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
@auto_docstring
def forward(self, hidden_states: torch.Tensor, attention_mask: Op... | 5 | 0 | 38 | 4 | 26 | 8 | 2 | 0.28 | 1 | 8 | 4 | 0 | 2 | 6 | 2 | 12 | 77 | 9 | 53 | 21 | 41 | 15 | 26 | 12 | 23 | 3 | 1 | 1 | 4 |
3,038 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsDecoupledEmbedding | from torch import nn
import torch.nn.functional as F
import torch
from typing import Any, Callable, Optional, Union
class IdeficsDecoupledEmbedding(nn.Embedding):
"""
Implements a decoupling of parameters to allow freezing (or not) a subset of the embeddings. In practise, the
regular `weight` can be traine... |
class IdeficsDecoupledEmbedding(nn.Embedding):
'''
Implements a decoupling of parameters to allow freezing (or not) a subset of the embeddings. In practise, the
regular `weight` can be trained or frozen (i.e. `partially_freeze=True`), and if `num_additional_embeddings` > 0,
then it will create `num_add... | 4 | 3 | 32 | 3 | 17 | 12 | 2 | 0.79 | 1 | 4 | 0 | 0 | 3 | 5 | 3 | 3 | 108 | 13 | 53 | 23 | 39 | 42 | 26 | 13 | 22 | 4 | 1 | 1 | 7 |
3,039 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsDecoupledLinear | from torch import nn
import torch.nn.functional as F
import torch
class IdeficsDecoupledLinear(nn.Linear):
"""
Implements a decoupling of parameters to allow freezing (or not) a subset of the parameters. In practise, the
regular `weight` can be trained or frozen (i.e. `partially_freeze=True`), and if `out_... |
class IdeficsDecoupledLinear(nn.Linear):
'''
Implements a decoupling of parameters to allow freezing (or not) a subset of the parameters. In practise, the
regular `weight` can be trained or frozen (i.e. `partially_freeze=True`), and if `out_additional_features` > 0,
then it will create `out_additional_... | 4 | 3 | 17 | 2 | 14 | 2 | 2 | 0.31 | 1 | 5 | 0 | 0 | 3 | 5 | 3 | 3 | 63 | 8 | 42 | 20 | 29 | 13 | 21 | 11 | 17 | 4 | 1 | 2 | 7 |
3,040 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsEmbedding | import torch.nn.functional as F
import torch
class IdeficsEmbedding(torch.nn.Module):
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
super().__init__()
self.dim = dim
self.max_position_embeddings = max_position_embeddings
self.base = base
in... |
class IdeficsEmbedding(torch.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 | 0 | 3 | 4 | 3 | 13 | 34 | 6 | 25 | 12 | 21 | 3 | 20 | 12 | 16 | 2 | 1 | 1 | 4 |
3,041 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsForVisionText2Text | from ...generation import GenerationMixin
from ...modeling_outputs import ModelOutput
import torch.nn.functional as F
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...processing_utils import Unpack
import torch
from ...cache_utils import Cache, DynamicCache
from typing import A... |
class IdeficsForVisionText2Text(IdeficsPreTrainedModel, GenerationMixin):
def __init__(self, config, vision_model=None):
pass
def tie_weights(self):
'''
Overwrite `transformers.modeling_utils.PreTrainedModel.tie_weights` to handle the case of
IdeficsDecoupledLinear and Idefics... | 8 | 2 | 22 | 2 | 16 | 4 | 3 | 0.24 | 2 | 9 | 3 | 0 | 11 | 2 | 12 | 13 | 279 | 38 | 195 | 72 | 142 | 46 | 97 | 33 | 84 | 12 | 2 | 3 | 37 |
3,042 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsGatedCrossAttentionLayer | import torch
from ...cache_utils import Cache, DynamicCache
from typing import Any, Callable, Optional, Union
from ...modeling_layers import GradientCheckpointingLayer
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...utils.deprecation import deprecate_kwarg
import torch.nn.func... |
class IdeficsGatedCrossAttentionLayer(GradientCheckpointingLayer):
def __init__(self, config: IdeficsConfig, layer_idx: Optional[int]=None):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
@auto_docstring
def forward(self, hidden_states: torch.Tensor, attent... | 5 | 1 | 70 | 8 | 52 | 10 | 9 | 0.19 | 1 | 10 | 4 | 0 | 2 | 10 | 2 | 12 | 141 | 17 | 104 | 26 | 91 | 20 | 57 | 16 | 54 | 11 | 1 | 2 | 17 |
3,043 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsMLP | from ...activations import ACT2FN
from torch import nn
class IdeficsMLP(nn.Module):
def __init__(self, hidden_size: int, intermediate_size: int, hidden_act: str):
super().__init__()
self.gate_proj = nn.Linear(hidden_size, intermediate_size, bias=False)
self.down_proj = nn.Linear(intermedia... |
class IdeficsMLP(nn.Module):
def __init__(self, hidden_size: int, intermediate_size: int, hidden_act: str):
pass
def forward(self, x):
pass | 3 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 1 | 3 | 0 | 0 | 2 | 4 | 2 | 12 | 15 | 1 | 14 | 12 | 6 | 0 | 9 | 7 | 6 | 1 | 1 | 0 | 2 |
3,044 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsModel | from typing import Any, Callable, Optional, Union
from ...utils.generic import OutputRecorder, check_model_inputs
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
import torch.nn.functional as F
from ...masking_utils import create_causal_mask
import torch
from ...processing_utils impor... | @auto_docstring
class IdeficsModel(IdeficsPreTrainedModel):
'''
Transformer decoder consisting of `config.num_hidden_layers` layers. Each layer is a [`IdeficsDecoderLayer`]
Args:
config: IdeficsConfig
'''
def __init__(self, config: IdeficsConfig):
pass
def freeze_releva... | 9 | 2 | 49 | 5 | 39 | 5 | 6 | 0.16 | 1 | 20 | 12 | 0 | 8 | 14 | 9 | 10 | 471 | 61 | 356 | 111 | 295 | 58 | 172 | 60 | 161 | 37 | 2 | 3 | 63 |
3,045 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsPreTrainedModel | from torch import nn
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PretrainedConfig, PreTrainedModel
from .perceiver import IdeficsPerceiverResampler
from ...utils.generic import OutputRecorder, check_model_inputs
from .configuration_idefics import IdeficsConfig
from ...utils import TransformersKwargs, auto_do... | @auto_docstring
class IdeficsPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
pass | 3 | 0 | 13 | 0 | 10 | 3 | 5 | 0.22 | 1 | 0 | 0 | 2 | 1 | 0 | 1 | 1 | 22 | 1 | 18 | 10 | 16 | 4 | 17 | 10 | 15 | 5 | 1 | 2 | 5 |
3,046 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/modeling_idefics.py | transformers.models.idefics.modeling_idefics.IdeficsRMSNorm | from torch import nn
import torch.nn.functional as F
import torch
class IdeficsRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
"""
IdeficsRMSNorm is equivalent to T5LayerNorm
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
... |
class IdeficsRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
'''
IdeficsRMSNorm is equivalent to T5LayerNorm
'''
pass
def forward(self, hidden_states):
pass
def extra_repr(self):
pass | 4 | 1 | 6 | 1 | 4 | 1 | 1 | 0.31 | 1 | 2 | 0 | 0 | 3 | 2 | 3 | 13 | 21 | 4 | 13 | 7 | 9 | 4 | 13 | 7 | 9 | 2 | 1 | 1 | 4 |
3,047 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/perceiver.py | transformers.models.idefics.perceiver.IdeficsMLP | from typing import Optional
import torch.nn as nn
from .configuration_idefics import IdeficsConfig
import torch
class IdeficsMLP(nn.Module):
def __init__(self, intermediate_size, config: IdeficsConfig):
"""Simple MLP block with intermediate_size and embedding size"""
super().__init__()
sel... |
class IdeficsMLP(nn.Module):
def __init__(self, intermediate_size, config: IdeficsConfig):
'''Simple MLP block with intermediate_size and embedding size'''
pass
def forward(self, hidden_states: Optional[tuple[torch.FloatTensor]]) -> torch.FloatTensor:
pass | 3 | 1 | 8 | 1 | 7 | 1 | 1 | 0.07 | 1 | 2 | 1 | 0 | 2 | 5 | 2 | 12 | 17 | 2 | 14 | 8 | 11 | 1 | 14 | 8 | 11 | 1 | 1 | 0 | 2 |
3,048 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/perceiver.py | transformers.models.idefics.perceiver.IdeficsPerceiverAttention | import torch
import torch.nn as nn
class IdeficsPerceiverAttention(nn.Module):
def __init__(self, embed_dim: int, n_heads: int, head_dim: int, qk_layer_norms: bool) -> None:
"""Perceiver Cross-Attention Module --> let long-form inputs be `context`, resampled embeddings be `latents`"""
super().__in... |
class IdeficsPerceiverAttention(nn.Module):
def __init__(self, embed_dim: int, n_heads: int, head_dim: int, qk_layer_norms: bool) -> None:
'''Perceiver Cross-Attention Module --> let long-form inputs be `context`, resampled embeddings be `latents`'''
pass
def forward(self, context: torch.Tens... | 3 | 2 | 31 | 5 | 15 | 11 | 2 | 0.68 | 1 | 4 | 0 | 0 | 2 | 13 | 2 | 12 | 63 | 11 | 31 | 22 | 28 | 21 | 31 | 22 | 28 | 2 | 1 | 1 | 4 |
3,049 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/perceiver.py | transformers.models.idefics.perceiver.IdeficsPerceiverResampler | import torch.nn as nn
from .configuration_idefics import IdeficsConfig
import torch
class IdeficsPerceiverResampler(nn.Module):
def __init__(self, config: IdeficsConfig, embed_dim: int, depth: int, n_heads: int, head_dim: int, n_latents: int) -> None:
"""
Instantiates a Perceiver Resampler that op... |
class IdeficsPerceiverResampler(nn.Module):
def __init__(self, config: IdeficsConfig, embed_dim: int, depth: int, n_heads: int, head_dim: int, n_latents: int) -> None:
'''
Instantiates a Perceiver Resampler that operates over a sequence of embeddings (say from a ResNet or ViT or
MAE) of a ... | 3 | 2 | 28 | 3 | 15 | 10 | 2 | 0.65 | 1 | 7 | 3 | 0 | 2 | 9 | 2 | 12 | 58 | 7 | 31 | 14 | 26 | 20 | 15 | 11 | 12 | 2 | 1 | 1 | 4 |
3,050 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/processing_idefics.py | transformers.models.idefics.processing_idefics.IdeficsImagesKwargs | from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, TextKwargs, Unpack
from typing import Callable, Optional, Union
class IdeficsImagesKwargs(ImagesKwargs, total=False):
transform: Optional[Callable]
image_size: Optional[dict[str, int]]
image_mean: Optional[Union[float, list[flo... |
class IdeficsImagesKwargs(ImagesKwargs, total=False):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 0 | 5 | 1 | 4 | 0 | 5 | 1 | 4 | 0 | 2 | 0 | 0 |
3,051 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/processing_idefics.py | transformers.models.idefics.processing_idefics.IdeficsProcessor | from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, TextKwargs, Unpack
from ...feature_extraction_utils import BatchFeature
from ...tokenization_utils_base import PreTokenizedInput, TextInput
from ...utils.deprecation import deprecate_kwarg
from typing import Callable, Optional, Union
from .... | null | 7 | 2 | 55 | 7 | 32 | 16 | 7 | 0.56 | 1 | 11 | 2 | 0 | 5 | 4 | 5 | 22 | 351 | 50 | 193 | 70 | 170 | 108 | 132 | 54 | 125 | 32 | 2 | 5 | 42 |
3,052 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/processing_idefics.py | transformers.models.idefics.processing_idefics.IdeficsProcessorKwargs | from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, TextKwargs, Unpack
class IdeficsProcessorKwargs(ProcessingKwargs, total=False):
text_kwargs: IdeficsTextKwargs
images_kwargs: IdeficsImagesKwargs
_defaults = {'text_kwargs': {'add_special_tokens': False, 'padding': 'longest', '... |
class IdeficsProcessorKwargs(ProcessingKwargs, total=False):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 0 | 12 | 2 | 11 | 0 | 4 | 2 | 3 | 0 | 3 | 0 | 0 |
3,053 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/processing_idefics.py | transformers.models.idefics.processing_idefics.IdeficsTextKwargs | from typing import Callable, Optional, Union
from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, TextKwargs, Unpack
class IdeficsTextKwargs(TextKwargs, total=False):
add_eos_token: Optional[bool]
add_end_of_utterance_token: Optional[bool] |
class IdeficsTextKwargs(TextKwargs, total=False):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 1 | 2 | 0 | 3 | 1 | 2 | 0 | 2 | 0 | 0 |
3,054 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/vision.py | transformers.models.idefics.vision.IdeficsVisionAttention | from torch import nn
from typing import Callable, Optional, Union
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS
from .configuration_idefics import IdeficsVisionConfig
import torch
class IdeficsVisionAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(... |
class IdeficsVisionAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, config: IdeficsVisionConfig):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, causal_attention_mask: Optional[torch.Tens... | 3 | 2 | 32 | 5 | 25 | 2 | 4 | 0.11 | 1 | 5 | 0 | 0 | 3 | 10 | 3 | 13 | 102 | 19 | 75 | 30 | 65 | 8 | 54 | 24 | 50 | 8 | 1 | 2 | 11 |
3,055 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/vision.py | transformers.models.idefics.vision.IdeficsVisionEmbeddings | import torch
from .configuration_idefics import IdeficsVisionConfig
from torch import nn
import math
class IdeficsVisionEmbeddings(nn.Module):
def __init__(self, config: IdeficsVisionConfig):
super().__init__()
self.config = config
self.embed_dim = config.hidden_size
self.image_siz... |
class IdeficsVisionEmbeddings(nn.Module):
def __init__(self, config: IdeficsVisionConfig):
pass
def interpolate_pos_encoding(self, embeddings: torch.Tensor, height: int, width: int) -> torch.Tensor:
'''
This method allows to interpolate the pre-trained position encodings, to be able t... | 4 | 1 | 31 | 4 | 24 | 3 | 3 | 0.15 | 1 | 7 | 1 | 0 | 3 | 9 | 3 | 13 | 97 | 13 | 74 | 28 | 70 | 11 | 53 | 28 | 49 | 5 | 1 | 2 | 10 |
3,056 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/vision.py | transformers.models.idefics.vision.IdeficsVisionEncoder | from .configuration_idefics import IdeficsVisionConfig
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
from typing import Callable, Optional, Union
import torch
from torch import nn
from ...utils import ModelOutput, can_return_tuple, logging
class IdeficsVisionEncoder(nn.Module):
"""
... |
class IdeficsVisionEncoder(nn.Module):
'''
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`IdeficsVisionEncoderLayer`].
Args:
config: IdeficsVisionConfig
'''
def __init__(self, config: IdeficsVisionConfig):
pass
... | 4 | 2 | 43 | 5 | 25 | 13 | 7 | 0.61 | 1 | 9 | 3 | 0 | 2 | 3 | 2 | 12 | 95 | 13 | 51 | 19 | 40 | 31 | 27 | 11 | 24 | 12 | 1 | 2 | 13 |
3,057 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/vision.py | transformers.models.idefics.vision.IdeficsVisionEncoderLayer | from .configuration_idefics import IdeficsVisionConfig
from torch import nn
from typing import Callable, Optional, Union
import torch
from ...modeling_layers import GradientCheckpointingLayer
class IdeficsVisionEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: IdeficsVisionConfig):
supe... |
class IdeficsVisionEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: IdeficsVisionConfig):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, causal_attention_mask: torch.Tensor, output_attentions: Optional[bool]=False) -> tuple[torch.FloatTensor]:
... | 3 | 1 | 23 | 3 | 16 | 5 | 2 | 0.31 | 1 | 6 | 3 | 0 | 2 | 5 | 2 | 12 | 48 | 6 | 32 | 17 | 23 | 10 | 21 | 11 | 18 | 2 | 1 | 1 | 3 |
3,058 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/vision.py | transformers.models.idefics.vision.IdeficsVisionMLP | from ...activations import ACT2FN
import torch
from torch import nn
class IdeficsVisionMLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.activation_fn = ACT2FN[config.hidden_act]
self.fc1 = nn.Linear(config.hidden_size, config.intermediate_siz... |
class IdeficsVisionMLP(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 4 | 2 | 12 | 13 | 1 | 12 | 7 | 9 | 0 | 12 | 7 | 9 | 1 | 1 | 0 | 2 |
3,059 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/vision.py | transformers.models.idefics.vision.IdeficsVisionModelOutput | from ...utils import ModelOutput, can_return_tuple, logging
from typing import Callable, Optional, Union
import torch
from dataclasses import dataclass
@dataclass
class IdeficsVisionModelOutput(ModelOutput):
"""
Base class for vision model's outputs that also contains image embeddings of the pooling of the las... | @dataclass
class IdeficsVisionModelOutput(ModelOutput):
'''
Base class for vision model's outputs that also contains image embeddings of the pooling of the last hidden states.
Args:
image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)` *optional* returned when model is initialized wi... | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 3.4 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 26 | 4 | 5 | 5 | 4 | 17 | 5 | 5 | 4 | 0 | 1 | 0 | 0 |
3,060 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics/vision.py | transformers.models.idefics.vision.IdeficsVisionTransformer | from .configuration_idefics import IdeficsVisionConfig
from typing import Callable, Optional, Union
import torch
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
from torch import nn
class IdeficsVisionTransformer(nn.Module):
def __init__(self, config: IdeficsVisionConfig):
supe... |
class IdeficsVisionTransformer(nn.Module):
def __init__(self, config: IdeficsVisionConfig):
pass
def forward(self, pixel_values: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=None, output_hidden_states: Optional[bool]=None, interpolate_pos_encoding: Optional[bool]=False, return_... | 3 | 1 | 27 | 4 | 21 | 2 | 4 | 0.09 | 1 | 7 | 4 | 0 | 2 | 5 | 2 | 12 | 56 | 9 | 43 | 20 | 33 | 4 | 24 | 13 | 21 | 6 | 1 | 1 | 7 |
3,061 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/configuration_idefics2.py | transformers.models.idefics2.configuration_idefics2.Idefics2Config | from ...configuration_utils import PretrainedConfig
from ..auto import CONFIG_MAPPING, AutoConfig
class Idefics2Config(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`Idefics2Model`]. It is used to instantiate a
Idefics2 model according to the specified arguments, d... |
class Idefics2Config(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`Idefics2Model`]. It is used to instantiate a
Idefics2 model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a s... | 2 | 1 | 53 | 5 | 47 | 1 | 11 | 0.57 | 1 | 4 | 2 | 0 | 1 | 6 | 1 | 1 | 95 | 10 | 54 | 19 | 43 | 31 | 28 | 10 | 26 | 11 | 1 | 1 | 11 |
3,062 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/configuration_idefics2.py | transformers.models.idefics2.configuration_idefics2.Idefics2PerceiverConfig | from ...configuration_utils import PretrainedConfig
class Idefics2PerceiverConfig(PretrainedConfig):
"""
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
documentation from [`PretrainedConfig`] for more information.
Args:
hidden_act... |
class Idefics2PerceiverConfig(PretrainedConfig):
'''
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
documentation from [`PretrainedConfig`] for more information.
Args:
hidden_act (`str` or `function`, *optional*, defaults to `"silu... | 2 | 1 | 28 | 0 | 28 | 0 | 2 | 0.77 | 1 | 2 | 0 | 0 | 1 | 9 | 1 | 1 | 56 | 3 | 30 | 24 | 16 | 23 | 15 | 12 | 13 | 2 | 1 | 1 | 2 |
3,063 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/configuration_idefics2.py | transformers.models.idefics2.configuration_idefics2.Idefics2VisionConfig | from ...configuration_utils import PretrainedConfig
class Idefics2VisionConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`Idefics2VisionModel`]. It is used to instantiate a
Idefics2 vision encoder according to the specified arguments, defining the model archite... |
class Idefics2VisionConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`Idefics2VisionModel`]. It is used to instantiate a
Idefics2 vision encoder according to the specified arguments, defining the model architecture. Instantiating a
configuration with the de... | 2 | 1 | 28 | 1 | 27 | 0 | 1 | 1.43 | 1 | 1 | 0 | 0 | 1 | 11 | 1 | 1 | 83 | 10 | 30 | 29 | 14 | 43 | 16 | 15 | 14 | 1 | 1 | 0 | 1 |
3,064 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/image_processing_idefics2.py | transformers.models.idefics2.image_processing_idefics2.Idefics2ImageProcessor | import numpy as np
from typing import Any, Optional, Union
from ...image_transforms import PaddingMode, pad, resize, to_channel_dimension_format
from ...image_utils import IMAGENET_STANDARD_MEAN, IMAGENET_STANDARD_STD, ChannelDimension, ImageInput, PILImageResampling, get_image_size, infer_channel_dimension_format, is_... |
class Idefics2ImageProcessor(BaseImageProcessor):
'''
Constructs a Idefics image processor.
Args:
do_convert_rgb (`bool`, *optional*, defaults to `True`):
Whether to convert the image to RGB. This is useful if the input image is of a different format e.g. RGBA.
Only has an e... | 9 | 6 | 47 | 3 | 31 | 13 | 6 | 0.57 | 1 | 11 | 3 | 0 | 7 | 11 | 7 | 27 | 416 | 35 | 243 | 109 | 168 | 139 | 103 | 42 | 94 | 27 | 3 | 3 | 48 |
3,065 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2BaseModelOutputWithPast | from ...cache_utils import Cache, DynamicCache
from dataclasses import dataclass
from ...modeling_outputs import BaseModelOutput, ModelOutput
import torch
from typing import Callable, Optional, Union
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
@dataclass
@auto_docstring(custom_in... | @dataclass
@auto_docstring(custom_intro="\n Base class for Idefics2 model's outputs that may also contain a past key/values (to speed up sequential decoding).\n ")
class Idefics2BaseModelOutputWithPast(ModelOutput):
'''
last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 4.83 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 36 | 1 | 6 | 6 | 5 | 29 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
3,066 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2CausalLMOutputWithPast | import torch
from dataclasses import dataclass
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from typing import Callable, Optional, Union
from ...cache_utils import Cache, DynamicCache
from ...modeling_outputs import BaseModelOutput, ModelOutput
@dataclass
@auto_docstring(custom_in... | @dataclass
@auto_docstring(custom_intro='\n Base class for Idefics2 causal language model (or autoregressive) outputs.\n ')
class Idefics2CausalLMOutputWithPast(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Language modeling loss (for... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.71 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 34 | 1 | 7 | 7 | 6 | 26 | 7 | 7 | 6 | 0 | 1 | 0 | 0 |
3,067 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2Connector | from torch import nn
class Idefics2Connector(nn.Module):
def __init__(self, config):
super().__init__()
self.modality_projection = Idefics2MLP(hidden_size=config.vision_config.hidden_size, intermediate_size=config.text_config.intermediate_size, output_size=config.text_config.hidden_size, hidden_ac... |
class Idefics2Connector(nn.Module):
def __init__(self, config):
pass
def forward(self, image_hidden_states, attention_mask):
pass | 3 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 1 | 3 | 2 | 0 | 2 | 2 | 2 | 12 | 15 | 1 | 14 | 5 | 11 | 0 | 9 | 5 | 6 | 1 | 1 | 0 | 2 |
3,068 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2Encoder | from ...modeling_outputs import BaseModelOutput, ModelOutput
from .configuration_idefics2 import Idefics2Config, Idefics2PerceiverConfig, Idefics2VisionConfig
from ...processing_utils import Unpack
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
import torch
from torch import nn
from ... |
class Idefics2Encoder(nn.Module):
'''
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`Idefics2EncoderLayer`].
Args:
config: Idefics2Config
'''
def __init__(self, config: Idefics2Config):
pass
@auto_docstring
... | 4 | 1 | 38 | 4 | 24 | 10 | 7 | 0.56 | 1 | 8 | 3 | 0 | 2 | 3 | 2 | 12 | 86 | 11 | 48 | 18 | 38 | 27 | 27 | 11 | 24 | 12 | 1 | 2 | 13 |
3,069 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2EncoderLayer | from torch import nn
from ...modeling_layers import GradientCheckpointingLayer
from ...processing_utils import Unpack
import torch
from .configuration_idefics2 import Idefics2Config, Idefics2PerceiverConfig, Idefics2VisionConfig
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
class I... |
class Idefics2EncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: Idefics2VisionConfig):
pass
@auto_docstring
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, **kwargs: Unpack[TransformersKwargs]) -> torch.FloatTensor:
pass | 4 | 0 | 22 | 3 | 15 | 5 | 2 | 0.37 | 1 | 5 | 2 | 0 | 2 | 5 | 2 | 12 | 47 | 6 | 30 | 16 | 22 | 11 | 21 | 11 | 18 | 2 | 1 | 1 | 3 |
3,070 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2ForConditionalGeneration | from ...generation import GenerationMixin
import torch
from ...cache_utils import Cache, DynamicCache
from torch import nn
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...processing_utils import Unpack
from typing import Callable, Optional, Union
@auto_docstring(custom_intro=... | @auto_docstring(custom_intro='\n The Idefics2 Model with a language modeling head. It is made up a SigLIP vision encoder, with a language modeling head on top.\n ')
class Idefics2ForConditionalGeneration(Idefics2PreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
def enable_input... | 13 | 2 | 20 | 2 | 13 | 5 | 2 | 0.41 | 2 | 8 | 2 | 0 | 10 | 6 | 11 | 12 | 259 | 37 | 158 | 64 | 113 | 65 | 81 | 34 | 68 | 9 | 2 | 2 | 29 |
3,071 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2MLP | from torch import nn
from ...activations import ACT2FN
class Idefics2MLP(nn.Module):
def __init__(self, hidden_size: int, intermediate_size: int, output_size: int, hidden_act: str):
super().__init__()
self.gate_proj = nn.Linear(hidden_size, intermediate_size, bias=False)
self.up_proj = nn.... |
class Idefics2MLP(nn.Module):
def __init__(self, hidden_size: int, intermediate_size: int, output_size: int, hidden_act: str):
pass
def forward(self, x):
pass | 3 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 1 | 3 | 0 | 0 | 2 | 4 | 2 | 12 | 16 | 1 | 15 | 13 | 6 | 0 | 9 | 7 | 6 | 1 | 1 | 0 | 2 |
3,072 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2Model | from ...processing_utils import Unpack
from ..auto import AutoModel
from ...cache_utils import Cache, DynamicCache
import torch
from typing import Callable, Optional, Union
from .configuration_idefics2 import Idefics2Config, Idefics2PerceiverConfig, Idefics2VisionConfig
from ...utils import TransformersKwargs, auto_doc... | @auto_docstring(custom_intro='\n Idefics2 model consisting of a SIGLIP vision encoder and Mistral language decoder\n ')
class Idefics2Model(Idefics2PreTrainedModel):
def __init__(self, config: Idefics2Config):
pass
def enable_input_require_grads(self):
'''
Enables the gradients f... | 14 | 4 | 24 | 3 | 18 | 3 | 3 | 0.17 | 1 | 13 | 7 | 0 | 7 | 11 | 7 | 8 | 226 | 33 | 166 | 67 | 125 | 29 | 88 | 35 | 78 | 20 | 2 | 3 | 29 |
3,073 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2MultiheadAttentionPoolingHead | from torch import nn
from .configuration_idefics2 import Idefics2Config, Idefics2PerceiverConfig, Idefics2VisionConfig
import torch
class Idefics2MultiheadAttentionPoolingHead(nn.Module):
"""Multihead Attention Pooling."""
def __init__(self, config: Idefics2VisionConfig):
super().__init__()
se... |
class Idefics2MultiheadAttentionPoolingHead(nn.Module):
'''Multihead Attention Pooling.'''
def __init__(self, config: Idefics2VisionConfig):
pass
def forward(self, hidden_state):
pass | 3 | 1 | 12 | 2 | 10 | 1 | 1 | 0.1 | 1 | 3 | 2 | 0 | 2 | 4 | 2 | 12 | 28 | 6 | 20 | 10 | 17 | 2 | 15 | 10 | 12 | 1 | 1 | 0 | 2 |
3,074 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2PerceiverAttention | from typing import Callable, Optional, Union
import torch
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...processing_utils import Unpack
from ...utils.deprecation import deprecate_kwarg
from torch import nn
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel... |
class Idefics2PerceiverAttention(nn.Module):
def __init__(self, config, layer_idx: Optional[int]=None) -> None:
'''Perceiver Cross-Attention Module --> let long-form inputs be `context`, resampled embeddings be `latents`'''
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', ve... | 4 | 2 | 49 | 10 | 32 | 7 | 4 | 0.22 | 1 | 5 | 0 | 1 | 2 | 12 | 2 | 12 | 99 | 21 | 64 | 32 | 52 | 14 | 47 | 23 | 44 | 7 | 1 | 2 | 8 |
3,075 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2PerceiverLayer | from ...processing_utils import Unpack
from ...cache_utils import Cache, DynamicCache
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...utils.deprecation import deprecate_kwarg
from typing import Callable, Optional, Union
from torch import nn
import torch
class Idefics2Perceive... |
class Idefics2PerceiverLayer(nn.Module):
def __init__(self, config, layer_idx: int):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, latents: torch.Tensor, context: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, position_ids: Option... | 4 | 1 | 34 | 4 | 23 | 7 | 2 | 0.3 | 1 | 6 | 2 | 0 | 2 | 9 | 2 | 12 | 70 | 9 | 47 | 25 | 34 | 14 | 28 | 15 | 25 | 3 | 1 | 1 | 4 |
3,076 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2PerceiverResampler | from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from torch import nn
import torch
from .configuration_idefics2 import Idefics2Config, Idefics2PerceiverConfig, Idefics2VisionConfig
from ...modeling_attn_mask_utils import _prepare_4d_attention_mask
from ...processing_utils import Unpack... | @auto_docstring(custom_intro='\n Idefics2 perceiver resampler model that performs `depth` blocks of cross-attention with a fixed\n ')
class Idefics2PerceiverResampler(Idefics2PreTrainedModel):
def __init__(self, config) -> None:
pass
@auto_docstring
def forward(self, context: torch.Tensor, at... | 5 | 1 | 26 | 4 | 20 | 2 | 2 | 0.07 | 1 | 5 | 2 | 0 | 2 | 9 | 2 | 3 | 56 | 10 | 43 | 23 | 36 | 3 | 25 | 19 | 22 | 3 | 2 | 1 | 4 |
3,077 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2PreTrainedModel | from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_idefics2 import Idefics2Config, Idefics2PerceiverConfig, Idefics2VisionConfig
from torch import nn
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
@auto_docstring
class Idefics2PreTrainedModel(... | @auto_docstring
class Idefics2PreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
pass | 3 | 0 | 18 | 2 | 16 | 0 | 7 | 0 | 1 | 0 | 0 | 4 | 1 | 0 | 1 | 1 | 28 | 3 | 25 | 11 | 23 | 0 | 20 | 11 | 18 | 7 | 1 | 2 | 7 |
3,078 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2RMSNorm | import torch
from torch import nn
class Idefics2RMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
"""
Idefics2RMSNorm is equivalent to T5LayerNorm
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.variance_epsilon = eps
... |
class Idefics2RMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
'''
Idefics2RMSNorm 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 |
3,079 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2VisionAttention | from typing import Callable, Optional, Union
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
import torch
from torch import nn
class Idefics2VisionAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config):
super().__init... |
class Idefics2VisionAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, **kwargs) -> tuple[torch.Tensor, Optional[torch.Tensor]]:
... | 3 | 2 | 36 | 7 | 28 | 2 | 4 | 0.09 | 1 | 4 | 0 | 1 | 2 | 11 | 2 | 12 | 77 | 15 | 57 | 26 | 49 | 5 | 41 | 21 | 38 | 5 | 1 | 2 | 7 |
3,080 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2VisionEmbeddings | from torch import nn
from .configuration_idefics2 import Idefics2Config, Idefics2PerceiverConfig, Idefics2VisionConfig
import torch
class Idefics2VisionEmbeddings(nn.Module):
"""
This is a modified version of `siglip.modelign_siglip.SiglipVisionEmbeddings` to enable images of variable
resolution.
The ... |
class Idefics2VisionEmbeddings(nn.Module):
'''
This is a modified version of `siglip.modelign_siglip.SiglipVisionEmbeddings` to enable images of variable
resolution.
The modifications are adapted from [Patch n' Pack: NaViT, a Vision Transformer for any Aspect Ratio and Resolution](https://huggingface.c... | 3 | 1 | 22 | 5 | 18 | 0 | 2 | 0.22 | 1 | 4 | 1 | 0 | 2 | 8 | 2 | 12 | 56 | 12 | 36 | 25 | 33 | 8 | 30 | 25 | 27 | 2 | 1 | 1 | 3 |
3,081 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2VisionMLP | from ...activations import ACT2FN
from torch import nn
import torch
class Idefics2VisionMLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.activation_fn = ACT2FN[config.hidden_act]
self.fc1 = nn.Linear(config.hidden_size, config.intermediate_si... |
class Idefics2VisionMLP(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 4 | 2 | 12 | 13 | 1 | 12 | 7 | 9 | 0 | 12 | 7 | 9 | 1 | 1 | 0 | 2 |
3,082 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/modeling_idefics2.py | transformers.models.idefics2.modeling_idefics2.Idefics2VisionTransformer | from ...modeling_outputs import BaseModelOutput, ModelOutput
from ...processing_utils import Unpack
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...utils.generic import check_model_inputs
from .configuration_idefics2 import Idefics2Config, Idefics2PerceiverConfig, Idefics2Visi... | @auto_docstring(custom_intro='\n Idefics2 vision encoder model that returnss raw image embeddings.\n ')
class Idefics2VisionTransformer(Idefics2PreTrainedModel):
def __init__(self, config: Idefics2VisionConfig):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self... | 8 | 1 | 17 | 2 | 15 | 1 | 3 | 0.05 | 1 | 6 | 4 | 0 | 4 | 5 | 4 | 5 | 76 | 12 | 61 | 25 | 49 | 3 | 35 | 18 | 30 | 8 | 2 | 1 | 11 |
3,083 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/processing_idefics2.py | transformers.models.idefics2.processing_idefics2.Idefics2ImagesKwargs | from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, Unpack
from typing import TYPE_CHECKING, Optional, Union
class Idefics2ImagesKwargs(ImagesKwargs, total=False):
image_seq_len: Optional[int] |
class Idefics2ImagesKwargs(ImagesKwargs, total=False):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 2 | 0 | 0 |
3,084 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/processing_idefics2.py | transformers.models.idefics2.processing_idefics2.Idefics2Processor | from typing import TYPE_CHECKING, Optional, Union
from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import AddedToken, TextInput
from itertools import accumulate
from ...feature_extraction_utils import BatchFeature
from ...image_utils import ImageInpu... |
class Idefics2Processor(ProcessorMixin):
'''
Constructs a IDEFICS2 processor which wraps a LLama tokenizer and IDEFICS2 image processor into a single processor.
[`IdeficsProcessor`] offers all the functionalities of [`Idefics2ImageProcessor`] and [`LlamaTokenizerFast`]. See
the docstring of [`~IdeficsP... | 4 | 2 | 31 | 4 | 18 | 9 | 5 | 0.59 | 1 | 9 | 2 | 0 | 6 | 4 | 6 | 23 | 214 | 33 | 114 | 43 | 99 | 67 | 82 | 35 | 75 | 15 | 2 | 4 | 27 |
3,085 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics2/processing_idefics2.py | transformers.models.idefics2.processing_idefics2.Idefics2ProcessorKwargs | from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, Unpack
class Idefics2ProcessorKwargs(ProcessingKwargs, total=False):
images_kwargs: Idefics2ImagesKwargs
_defaults = {'text_kwargs': {'add_special_tokens': True, 'padding': False, 'is_split_into_words': False}, 'images_kwargs': {}} |
class Idefics2ProcessorKwargs(ProcessingKwargs, total=False):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 1 | 10 | 2 | 9 | 0 | 3 | 2 | 2 | 0 | 3 | 0 | 0 |
3,086 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/configuration_idefics3.py | transformers.models.idefics3.configuration_idefics3.Idefics3Config | from ...configuration_utils import PretrainedConfig
from ..auto import CONFIG_MAPPING, AutoConfig
class Idefics3Config(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`Idefics3Model`]. It is used to instantiate a
Idefics3 model according to the specified arguments, d... |
class Idefics3Config(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`Idefics3Model`]. It is used to instantiate a
Idefics3 model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a s... | 2 | 1 | 38 | 4 | 34 | 0 | 7 | 0.89 | 1 | 3 | 1 | 0 | 1 | 6 | 1 | 1 | 79 | 9 | 37 | 20 | 25 | 33 | 20 | 10 | 18 | 7 | 1 | 1 | 7 |
3,087 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/configuration_idefics3.py | transformers.models.idefics3.configuration_idefics3.Idefics3VisionConfig | from ...configuration_utils import PretrainedConfig
class Idefics3VisionConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`Idefics3VisionModel`]. It is used to instantiate a
Idefics3 vision encoder according to the specified arguments, defining the model archite... |
class Idefics3VisionConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`Idefics3VisionModel`]. It is used to instantiate a
Idefics3 vision encoder according to the specified arguments, defining the model architecture. Instantiating a
configuration with the de... | 2 | 1 | 28 | 1 | 27 | 0 | 1 | 1.43 | 1 | 1 | 0 | 0 | 1 | 11 | 1 | 1 | 83 | 10 | 30 | 29 | 14 | 43 | 16 | 15 | 14 | 1 | 1 | 0 | 1 |
3,088 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/image_processing_idefics3.py | transformers.models.idefics3.image_processing_idefics3.Idefics3ImageProcessor | import numpy as np
from typing import Any, Optional, Union
import math
from ...image_transforms import PaddingMode, pad, to_channel_dimension_format, to_pil_image
from ...image_utils import IMAGENET_STANDARD_MEAN, IMAGENET_STANDARD_STD, ChannelDimension, ImageInput, PILImageResampling, get_image_size, infer_channel_dim... |
class Idefics3ImageProcessor(BaseImageProcessor):
'''
Constructs a Idefics3 image processor.
Args:
do_convert_rgb (`bool`, *optional*, defaults to `True`):
Whether to convert the image to RGB. This is useful if the input image is of a different format e.g. RGBA.
Only has an ... | 10 | 8 | 70 | 5 | 46 | 19 | 8 | 0.53 | 1 | 12 | 3 | 0 | 7 | 12 | 7 | 27 | 601 | 47 | 363 | 144 | 283 | 191 | 171 | 72 | 162 | 34 | 3 | 3 | 66 |
3,089 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3BaseModelOutputWithPast | from typing import Callable, Optional, Union
import torch
from ...cache_utils import Cache, DynamicCache
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from dataclasses import dataclass
from ...modeling_outputs import BaseModelOutput, ModelOutput
@dataclass
@auto_docstring(custom_in... | @dataclass
@auto_docstring(custom_intro="\n Base class for Idefics3 model's outputs that may also contain a past key/values (to speed up sequential decoding).\n ")
class Idefics3BaseModelOutputWithPast(ModelOutput):
'''
last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 4.83 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 36 | 1 | 6 | 6 | 5 | 29 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
3,090 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3CausalLMOutputWithPast | from ...modeling_outputs import BaseModelOutput, ModelOutput
from ...cache_utils import Cache, DynamicCache
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from typing import Callable, Optional, Union
from dataclasses import dataclass
import torch
@dataclass
@auto_docstring(custom_in... | @dataclass
@auto_docstring(custom_intro='\n Base class for Idefics causal language model (or autoregressive) outputs.\n ')
class Idefics3CausalLMOutputWithPast(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Language modeling loss (for ... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.71 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 35 | 2 | 7 | 7 | 6 | 26 | 7 | 7 | 6 | 0 | 1 | 0 | 0 |
3,091 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3Connector | from torch import nn
class Idefics3Connector(nn.Module):
def __init__(self, config):
super().__init__()
self.scale_factor = config.scale_factor
self.modality_projection = Idefics3SimpleMLP(config)
def pixel_shuffle(self, x, scale_factor=2):
bsz, seq, embed_dim = x.size()
... |
class Idefics3Connector(nn.Module):
def __init__(self, config):
pass
def pixel_shuffle(self, x, scale_factor=2):
pass
def forward(self, image_hidden_states):
pass | 4 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 1 | 3 | 1 | 0 | 3 | 2 | 3 | 13 | 21 | 2 | 19 | 8 | 15 | 0 | 19 | 8 | 15 | 1 | 1 | 0 | 3 |
3,092 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3Encoder | from .configuration_idefics3 import Idefics3Config, Idefics3VisionConfig
from ...modeling_outputs import BaseModelOutput, ModelOutput
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from torch import nn
import torch
from typing import Callable, Optional, Union
class Idefics3Encoder(n... |
class Idefics3Encoder(nn.Module):
'''
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`Idefics3EncoderLayer`].
Args:
config: Idefics3Config
'''
def __init__(self, config: Idefics3Config):
pass
@auto_docstring
... | 4 | 1 | 38 | 4 | 24 | 10 | 7 | 0.56 | 1 | 8 | 3 | 0 | 2 | 3 | 2 | 12 | 86 | 11 | 48 | 18 | 38 | 27 | 27 | 11 | 24 | 12 | 1 | 2 | 13 |
3,093 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3EncoderLayer | from ...modeling_layers import GradientCheckpointingLayer
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...processing_utils import Unpack
import torch
from torch import nn
from .configuration_idefics3 import Idefics3Config, Idefics3VisionConfig
class Idefics3EncoderLayer(Gradi... |
class Idefics3EncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: Idefics3VisionConfig):
pass
@auto_docstring
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, **kwargs: Unpack[TransformersKwargs]) -> torch.FloatTensor:
pass | 4 | 0 | 22 | 3 | 15 | 5 | 2 | 0.37 | 1 | 5 | 2 | 0 | 2 | 5 | 2 | 12 | 47 | 6 | 30 | 16 | 22 | 11 | 21 | 11 | 18 | 2 | 1 | 1 | 3 |
3,094 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3ForConditionalGeneration | from ...cache_utils import Cache, DynamicCache
from torch import nn
from ...generation import GenerationMixin
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from ...processing_utils import Unpack
import torch
from typing import Callable, Optional, Union
@auto_docstring(custom_intro=... | @auto_docstring(custom_intro='\n The Idefics3 Model with a language modeling head. It is made up a SigLIP vision encoder, with a language modeling head on top.\n ')
class Idefics3ForConditionalGeneration(Idefics3PreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
def enable_input... | 13 | 2 | 22 | 2 | 13 | 7 | 2 | 0.55 | 2 | 5 | 2 | 0 | 10 | 6 | 10 | 11 | 261 | 34 | 147 | 58 | 106 | 81 | 75 | 30 | 63 | 9 | 2 | 2 | 26 |
3,095 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3Model | from ...modeling_flash_attention_utils import FlashAttentionKwargs
from typing import Callable, Optional, Union
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from .configuration_idefics3 import Idefics3Config, Idefics3VisionConfig
from ...cache_utils import Cache, DynamicCache
impor... | @auto_docstring(custom_intro='\n Idefics3 model consisting of a SIGLIP vision encoder and Llama3 language decoder\n ')
class Idefics3Model(Idefics3PreTrainedModel):
def __init__(self, config: Idefics3Config):
pass
def enable_input_require_grads(self):
'''
Enables the gradients fo... | 14 | 4 | 23 | 3 | 17 | 3 | 3 | 0.21 | 1 | 13 | 6 | 0 | 7 | 11 | 7 | 8 | 218 | 31 | 155 | 66 | 114 | 33 | 82 | 34 | 72 | 18 | 2 | 2 | 27 |
3,096 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3PreTrainedModel | from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging
from .configuration_idefics3 import Idefics3Config, Idefics3VisionConfig
from torch import nn
@auto_docstring
class Idefics3PreTrainedModel(PreTrainedModel):
con... | @auto_docstring
class Idefics3PreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
pass | 3 | 0 | 18 | 2 | 16 | 0 | 7 | 0.04 | 1 | 0 | 0 | 3 | 1 | 0 | 1 | 1 | 29 | 3 | 25 | 11 | 23 | 1 | 20 | 11 | 18 | 7 | 1 | 2 | 7 |
3,097 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3RMSNorm | from torch import nn
import torch
class Idefics3RMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
"""
Idefics3RMSNorm is equivalent to T5LayerNorm
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.variance_epsilon = eps
... |
class Idefics3RMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
'''
Idefics3RMSNorm 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 |
3,098 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3SimpleMLP | from torch import nn
class Idefics3SimpleMLP(nn.Module):
def __init__(self, config):
super().__init__()
input_size = config.vision_config.hidden_size * config.scale_factor ** 2
output_size = config.text_config.hidden_size
self.proj = nn.Linear(input_size, output_size, bias=False)
... |
class Idefics3SimpleMLP(nn.Module):
def __init__(self, config):
pass
def forward(self, x):
pass | 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 12 | 9 | 1 | 8 | 6 | 5 | 0 | 8 | 6 | 5 | 1 | 1 | 0 | 2 |
3,099 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/idefics3/modeling_idefics3.py | transformers.models.idefics3.modeling_idefics3.Idefics3VisionAttention | import torch
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from torch import nn
from typing import Callable, Optional, Union
class Idefics3VisionAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config):
super().__init... |
class Idefics3VisionAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, **kwargs) -> tuple[torch.Tensor, Optional[torch.Tensor]]:
... | 3 | 2 | 36 | 7 | 28 | 2 | 4 | 0.09 | 1 | 4 | 0 | 1 | 2 | 11 | 2 | 12 | 77 | 15 | 57 | 26 | 49 | 5 | 41 | 21 | 38 | 5 | 1 | 2 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.