id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,700 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/image_processing_efficientformer.py | transformers.models.deprecated.efficientformer.image_processing_efficientformer.EfficientFormerImageProcessor | import numpy as np
from ....utils import TensorType, logging
from ....image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ....image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, ChannelDimension, ImageInput, PILImageResampling, infer_channel_dimension_format, is_batched, is_sc... |
class EfficientFormerImageProcessor(BaseImageProcessor):
'''
Constructs a EfficientFormer image processor.
Args:
do_resize (`bool`, *optional*, defaults to `True`):
Whether to resize the image's (height, width) dimensions to the specified `(size["height"],
size["width"])`. C... | 4 | 3 | 78 | 6 | 49 | 23 | 9 | 0.69 | 1 | 8 | 2 | 0 | 3 | 11 | 3 | 23 | 275 | 22 | 150 | 56 | 108 | 103 | 61 | 18 | 57 | 19 | 3 | 1 | 27 |
1,701 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerConvMlp | from typing import Optional, Union
from ....activations import ACT2FN
from .configuration_efficientformer import EfficientFormerConfig
import torch
from torch import nn
class EfficientFormerConvMlp(nn.Module):
def __init__(self, config: EfficientFormerConfig, in_features: int, hidden_features: Optional[int]=None,... |
class EfficientFormerConvMlp(nn.Module):
def __init__(self, config: EfficientFormerConfig, in_features: int, hidden_features: Optional[int]=None, out_features: Optional[int]=None, drop: float=0.0):
pass
def forward(self, hidden_state: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 16 | 3 | 13 | 0 | 1 | 0 | 1 | 5 | 1 | 0 | 2 | 6 | 2 | 12 | 33 | 6 | 27 | 16 | 17 | 0 | 20 | 9 | 17 | 1 | 1 | 0 | 2 |
1,702 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerConvStem | import torch
from torch import nn
from .configuration_efficientformer import EfficientFormerConfig
class EfficientFormerConvStem(nn.Module):
def __init__(self, config: EfficientFormerConfig, out_channels: int):
super().__init__()
self.convolution1 = nn.Conv2d(config.num_channels, out_channels // 2... |
class EfficientFormerConvStem(nn.Module):
def __init__(self, config: EfficientFormerConfig, out_channels: int):
pass
def forward(self, pixel_values: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 9 | 2 | 7 | 0 | 1 | 0 | 1 | 4 | 1 | 0 | 2 | 5 | 2 | 12 | 19 | 5 | 14 | 9 | 11 | 0 | 14 | 9 | 11 | 1 | 1 | 0 | 2 |
1,703 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerDenseMlp | import torch
from ....activations import ACT2FN
from .configuration_efficientformer import EfficientFormerConfig
from torch import nn
from typing import Optional, Union
class EfficientFormerDenseMlp(nn.Module):
def __init__(self, config: EfficientFormerConfig, in_features: int, hidden_features: Optional[int]=None... |
class EfficientFormerDenseMlp(nn.Module):
def __init__(self, config: EfficientFormerConfig, in_features: int, hidden_features: Optional[int]=None, out_features: Optional[int]=None):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 12 | 1 | 11 | 0 | 1 | 0 | 1 | 4 | 1 | 0 | 2 | 4 | 2 | 12 | 25 | 3 | 22 | 13 | 13 | 0 | 16 | 7 | 13 | 1 | 1 | 0 | 2 |
1,704 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerDropPath | import torch
from typing import Optional, Union
from torch import nn
class EfficientFormerDropPath(nn.Module):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks)."""
def __init__(self, drop_prob: Optional[float]=None) -> None:
super().__init__()
self.dro... |
class EfficientFormerDropPath(nn.Module):
'''Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).'''
def __init__(self, drop_prob: Optional[float]=None) -> None:
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass
def extra_re... | 4 | 1 | 2 | 0 | 2 | 0 | 1 | 0.13 | 1 | 4 | 0 | 0 | 3 | 1 | 3 | 13 | 12 | 3 | 8 | 5 | 4 | 1 | 8 | 5 | 4 | 1 | 1 | 0 | 3 |
1,705 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerEncoder | from .configuration_efficientformer import EfficientFormerConfig
from torch import nn
import torch
from ....modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, ImageClassifierOutput
class EfficientFormerEncoder(nn.Module):
def __init__(self, config: EfficientFormerConfig):
super().__init_... |
class EfficientFormerEncoder(nn.Module):
def __init__(self, config: EfficientFormerConfig):
pass
def forward(self, hidden_states: torch.Tensor, output_hidden_states: bool=False, output_attentions: bool=False, return_dict: bool=True) -> BaseModelOutput:
pass | 3 | 0 | 27 | 5 | 22 | 0 | 6 | 0 | 1 | 10 | 5 | 0 | 2 | 3 | 2 | 12 | 55 | 10 | 45 | 19 | 36 | 0 | 30 | 13 | 27 | 9 | 1 | 2 | 12 |
1,706 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerFlat | from torch import nn
import torch
class EfficientFormerFlat(nn.Module):
def __init__(self):
super().__init__()
def forward(self, hidden_states: torch.Tensor) -> tuple[torch.Tensor]:
hidden_states = hidden_states.flatten(2).transpose(1, 2)
return hidden_states |
class EfficientFormerFlat(nn.Module):
def __init__(self):
pass
def forward(self, hidden_states: torch.Tensor) -> tuple[torch.Tensor]:
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 0 | 2 | 12 | 7 | 1 | 6 | 3 | 3 | 0 | 6 | 3 | 3 | 1 | 1 | 0 | 2 |
1,707 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerForImageClassification | import torch
from torch import nn
from typing import Optional, Union
from .configuration_efficientformer import EfficientFormerConfig
from ....modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, ImageClassifierOutput
from ....utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, a... | @add_start_docstrings('\n EfficientFormer Model transformer with an image classification head on top (a linear layer on top of the final\n hidden state of the [CLS] token) e.g. for ImageNet.\n ', EFFICIENTFORMER_START_DOCSTRING)
class EfficientFormerForImageClassification(EfficientFormerPreTrainedModel):
... | 6 | 1 | 37 | 5 | 28 | 4 | 7 | 0.13 | 1 | 8 | 3 | 0 | 2 | 3 | 2 | 132 | 82 | 11 | 63 | 20 | 46 | 8 | 32 | 12 | 29 | 12 | 3 | 3 | 14 |
1,708 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerForImageClassificationWithTeacher | from ....utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from .configuration_efficientformer import EfficientFormerConfig
import torch
from torch import nn
from typing import Optional, Union
@add_start_docstrings('\n EfficientFormer Model tr... | @add_start_docstrings('\n EfficientFormer Model transformer with image classification heads on top (a linear layer on top of the final hidden\n state of the [CLS] token and a linear layer on top of the final hidden state of the distillation token) e.g. for\n ImageNet.\n\n <Tip warning={true}>\n\n ... | 6 | 0 | 25 | 4 | 19 | 2 | 3 | 0.09 | 1 | 7 | 3 | 0 | 2 | 4 | 2 | 132 | 58 | 9 | 45 | 20 | 29 | 4 | 19 | 13 | 16 | 3 | 3 | 1 | 6 |
1,709 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerForImageClassificationWithTeacherOutput | from typing import Optional, Union
import torch
from dataclasses import dataclass
from ....utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
@dataclass
class EfficientFormerForImageClassificationWithTeacherOutput(ModelOutput):
"""
Output ... | @dataclass
class EfficientFormerForImageClassificationWithTeacherOutput(ModelOutput):
'''
Output type of [`EfficientFormerForImageClassificationWithTeacher`].
Args:
logits (`torch.FloatTensor` of shape `(batch_size, config.num_labels)`):
Prediction scores as the average of the cls_logits... | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 3.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 28 | 2 | 6 | 6 | 5 | 20 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
1,710 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerIntermediateStage | from .configuration_efficientformer import EfficientFormerConfig
import torch
from torch import nn
class EfficientFormerIntermediateStage(nn.Module):
def __init__(self, config: EfficientFormerConfig, index: int):
super().__init__()
self.meta4D_layers = EfficientFormerMeta4DLayers(config, index)
... |
class EfficientFormerIntermediateStage(nn.Module):
def __init__(self, config: EfficientFormerConfig, index: int):
pass
def forward(self, hidden_states: torch.Tensor) -> tuple[torch.Tensor]:
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 5 | 2 | 0 | 2 | 1 | 2 | 12 | 8 | 1 | 7 | 4 | 4 | 0 | 7 | 4 | 4 | 1 | 1 | 0 | 2 |
1,711 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerLastStage | from torch import nn
import torch
from .configuration_efficientformer import EfficientFormerConfig
class EfficientFormerLastStage(nn.Module):
def __init__(self, config: EfficientFormerConfig):
super().__init__()
self.meta4D_layers = EfficientFormerMeta4DLayers(config, -1)
self.flat = Effic... |
class EfficientFormerLastStage(nn.Module):
def __init__(self, config: EfficientFormerConfig):
pass
def forward(self, hidden_states: torch.Tensor, output_attentions: bool=False) -> tuple[torch.Tensor]:
pass | 3 | 0 | 6 | 1 | 5 | 0 | 1 | 0 | 1 | 7 | 4 | 0 | 2 | 3 | 2 | 12 | 13 | 2 | 11 | 6 | 8 | 0 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
1,712 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerMeta3D | from .configuration_efficientformer import EfficientFormerConfig
import torch
from torch import nn
class EfficientFormerMeta3D(nn.Module):
def __init__(self, config: EfficientFormerConfig, dim: int, drop_path: float=0.0):
super().__init__()
self.token_mixer = EfficientFormerSelfAttention(dim=confi... |
class EfficientFormerMeta3D(nn.Module):
def __init__(self, config: EfficientFormerConfig, dim: int, drop_path: float=0.0):
pass
def forward(self, hidden_states: torch.Tensor, output_attentions: bool=False) -> tuple[torch.Tensor]:
pass | 3 | 0 | 21 | 4 | 17 | 1 | 3 | 0.03 | 1 | 9 | 4 | 0 | 2 | 8 | 2 | 12 | 43 | 8 | 35 | 16 | 32 | 1 | 24 | 16 | 21 | 3 | 1 | 1 | 5 |
1,713 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerMeta3DLayers | from .configuration_efficientformer import EfficientFormerConfig
import torch
from torch import nn
class EfficientFormerMeta3DLayers(nn.Module):
def __init__(self, config: EfficientFormerConfig):
super().__init__()
drop_paths = [config.drop_path_rate * (block_idx + sum(config.depths[:-1])) for blo... |
class EfficientFormerMeta3DLayers(nn.Module):
def __init__(self, config: EfficientFormerConfig):
pass
def forward(self, hidden_states: torch.Tensor, output_attentions: bool=False) -> tuple[torch.Tensor]:
pass | 3 | 0 | 13 | 3 | 11 | 0 | 4 | 0 | 1 | 7 | 2 | 0 | 2 | 1 | 2 | 12 | 28 | 6 | 22 | 9 | 19 | 0 | 17 | 8 | 14 | 6 | 1 | 2 | 7 |
1,714 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerMeta4D | import torch
from .configuration_efficientformer import EfficientFormerConfig
from torch import nn
class EfficientFormerMeta4D(nn.Module):
def __init__(self, config: EfficientFormerConfig, dim: int, drop_path: float=0.0):
super().__init__()
pool_size = config.pool_size if config.pool_size is not N... |
class EfficientFormerMeta4D(nn.Module):
def __init__(self, config: EfficientFormerConfig, dim: int, drop_path: float=0.0):
pass
def forward(self, hidden_states: torch.Tensor) -> tuple[torch.Tensor]:
pass | 3 | 0 | 14 | 2 | 12 | 0 | 3 | 0 | 1 | 8 | 4 | 0 | 2 | 6 | 2 | 12 | 30 | 5 | 25 | 13 | 22 | 0 | 20 | 13 | 17 | 4 | 1 | 1 | 6 |
1,715 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerMeta4DLayers | import torch
from torch import nn
from .configuration_efficientformer import EfficientFormerConfig
class EfficientFormerMeta4DLayers(nn.Module):
def __init__(self, config: EfficientFormerConfig, stage_idx: int):
super().__init__()
num_layers = config.depths[stage_idx] if stage_idx != -1 else confi... |
class EfficientFormerMeta4DLayers(nn.Module):
def __init__(self, config: EfficientFormerConfig, stage_idx: int):
pass
def forward(self, hidden_states: torch.Tensor) -> tuple[torch.Tensor]:
pass | 3 | 0 | 10 | 1 | 9 | 0 | 2 | 0 | 1 | 6 | 2 | 0 | 2 | 1 | 2 | 12 | 21 | 2 | 19 | 8 | 16 | 0 | 10 | 7 | 7 | 2 | 1 | 1 | 4 |
1,716 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerModel | from ....utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from torch import nn
from ....modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, ImageClassifierOutput
import torch
from typing import Optional, Union
from .configuration... | @add_start_docstrings('The bare EfficientFormer Model transformer outputting raw hidden-states without any specific head on top.', EFFICIENTFORMER_START_DOCSTRING)
class EfficientFormerModel(EfficientFormerPreTrainedModel):
def __init__(self, config: EfficientFormerConfig):
pass
@add_start_docstrings_t... | 6 | 0 | 22 | 4 | 18 | 1 | 4 | 0.02 | 1 | 9 | 4 | 0 | 2 | 4 | 2 | 132 | 54 | 8 | 45 | 19 | 28 | 1 | 23 | 12 | 20 | 6 | 3 | 1 | 7 |
1,717 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerPatchEmbeddings | import torch
from .configuration_efficientformer import EfficientFormerConfig
from torch import nn
class EfficientFormerPatchEmbeddings(nn.Module):
"""
This class performs downsampling between two stages. For the input tensor with the shape [batch_size, num_channels,
height, width] it produces output tenso... |
class EfficientFormerPatchEmbeddings(nn.Module):
'''
This class performs downsampling between two stages. For the input tensor with the shape [batch_size, num_channels,
height, width] it produces output tensor with the shape [batch_size, num_channels, height/stride, width/stride]
'''
def __init__(... | 3 | 1 | 12 | 2 | 10 | 0 | 2 | 0.19 | 1 | 6 | 1 | 0 | 2 | 3 | 2 | 12 | 30 | 5 | 21 | 8 | 18 | 4 | 13 | 8 | 10 | 2 | 1 | 1 | 4 |
1,718 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerPooling | from torch import nn
import torch
class EfficientFormerPooling(nn.Module):
def __init__(self, pool_size: int):
super().__init__()
self.pool = nn.AvgPool2d(pool_size, stride=1, padding=pool_size // 2, count_include_pad=False)
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
... |
class EfficientFormerPooling(nn.Module):
def __init__(self, pool_size: int):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 3 | 0 | 0 | 2 | 1 | 2 | 12 | 8 | 1 | 7 | 5 | 4 | 0 | 7 | 5 | 4 | 1 | 1 | 0 | 2 |
1,719 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerPreTrainedModel | from .configuration_efficientformer import EfficientFormerConfig
from ....modeling_utils import PreTrainedModel
from torch import nn
class EfficientFormerPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
mo... |
class EfficientFormerPreTrainedModel(PreTrainedModel):
'''
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
'''
def _init_weights(self, module: nn.Module):
'''Initialize the weights'''
pass | 2 | 2 | 9 | 0 | 8 | 1 | 4 | 0.38 | 1 | 0 | 0 | 3 | 1 | 0 | 1 | 130 | 20 | 2 | 13 | 6 | 11 | 5 | 12 | 6 | 10 | 4 | 2 | 2 | 4 |
1,720 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/efficientformer/modeling_efficientformer.py | transformers.models.deprecated.efficientformer.modeling_efficientformer.EfficientFormerSelfAttention | import itertools
import torch
from torch import nn
class EfficientFormerSelfAttention(nn.Module):
def __init__(self, dim: int, key_dim: int, num_heads: int, attention_ratio: int, resolution: int):
super().__init__()
self.num_heads = num_heads
self.key_dim = key_dim
self.attention_r... |
class EfficientFormerSelfAttention(nn.Module):
def __init__(self, dim: int, key_dim: int, num_heads: int, attention_ratio: int, resolution: int):
pass
@torch.no_grad()
def train(self, mode=True):
pass
def forward(self, hidden_states: torch.Tensor, output_attentions: bool=False) -> tup... | 5 | 0 | 19 | 2 | 17 | 1 | 3 | 0.04 | 1 | 7 | 0 | 0 | 3 | 11 | 3 | 13 | 62 | 8 | 52 | 30 | 47 | 2 | 46 | 29 | 42 | 4 | 1 | 3 | 10 |
1,721 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/configuration_ernie_m.py | transformers.models.deprecated.ernie_m.configuration_ernie_m.ErnieMConfig | from ....configuration_utils import PretrainedConfig
class ErnieMConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`ErnieMModel`]. It is used to instantiate a
Ernie-M model according to the specified arguments, defining the model architecture. Instantiating a co... |
class ErnieMConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`ErnieMModel`]. It is used to instantiate a
Ernie-M model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a simila... | 2 | 1 | 32 | 0 | 32 | 0 | 1 | 1.31 | 1 | 4 | 0 | 0 | 1 | 13 | 1 | 33 | 87 | 6 | 35 | 34 | 16 | 46 | 18 | 17 | 16 | 1 | 2 | 0 | 1 |
1,722 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMAttention | from ....pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer
from ....cache_utils import Cache
from ....utils.deprecation import deprecate_kwarg
from torch import nn, tensor
import torch
from typing import Optional, Union
class ErnieMAttention(nn.Module):
def __init__(self, config, position_... |
class ErnieMAttention(nn.Module):
def __init__(self, config, position_embedding_type=None):
pass
def prune_heads(self, heads):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[to... | 5 | 0 | 15 | 1 | 13 | 1 | 1 | 0.07 | 1 | 5 | 1 | 0 | 3 | 3 | 3 | 13 | 47 | 4 | 41 | 20 | 28 | 3 | 22 | 11 | 18 | 2 | 1 | 1 | 4 |
1,723 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMEmbeddings | import torch
from torch import nn, tensor
from typing import Optional, Union
class ErnieMEmbeddings(nn.Module):
"""Construct the embeddings from word and position embeddings."""
def __init__(self, config):
super().__init__()
self.hidden_size = config.hidden_size
self.word_embeddings = ... |
class ErnieMEmbeddings(nn.Module):
'''Construct the embeddings from word and position embeddings.'''
def __init__(self, config):
pass
def forward(self, input_ids: Optional[torch.LongTensor]=None, position_ids: Optional[torch.LongTensor]=None, inputs_embeds: Optional[torch.LongTensor]=None, past_k... | 3 | 1 | 18 | 1 | 16 | 1 | 3 | 0.06 | 1 | 3 | 0 | 0 | 2 | 6 | 2 | 12 | 39 | 4 | 33 | 20 | 24 | 2 | 25 | 14 | 22 | 4 | 1 | 2 | 5 |
1,724 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMEncoder | from typing import Optional, Union
from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
import torch
from ....cache_utils import Cache
from torch ... |
class ErnieMEncoder(nn.Module):
def __init__(self, config):
pass
def forward(self, input_embeds: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, past_key_values: Optional[Cache]=None, output_attentions: Optional[bool]=False, output_hidden_s... | 3 | 0 | 22 | 3 | 19 | 0 | 6 | 0 | 1 | 8 | 2 | 0 | 2 | 2 | 2 | 12 | 45 | 6 | 39 | 22 | 27 | 0 | 23 | 13 | 20 | 10 | 1 | 2 | 11 |
1,725 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMEncoderLayer | from ....activations import ACT2FN
from torch import nn, tensor
import torch
from typing import Optional, Union
from ....cache_utils import Cache
from ....utils.deprecation import deprecate_kwarg
class ErnieMEncoderLayer(nn.Module):
def __init__(self, config):
super().__init__()
dropout = 0.1 if c... |
class ErnieMEncoderLayer(nn.Module):
def __init__(self, config):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, past_ke... | 4 | 0 | 30 | 2 | 27 | 1 | 4 | 0.02 | 1 | 5 | 1 | 0 | 2 | 9 | 2 | 12 | 61 | 5 | 55 | 23 | 45 | 1 | 33 | 16 | 30 | 4 | 1 | 1 | 7 |
1,726 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMForInformationExtraction | from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
from ....utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_... | @add_start_docstrings('ErnieMForInformationExtraction is a Ernie-M Model with two linear layer on top of the hidden-states output to\n compute `start_prob` and `end_prob`, designed for Universal Information Extraction.', ERNIE_M_START_DOCSTRING)
class ErnieMForInformationExtraction(ErnieMPreTrainedModel):
def _... | 5 | 1 | 40 | 3 | 32 | 5 | 4 | 0.15 | 1 | 6 | 2 | 0 | 2 | 4 | 2 | 132 | 83 | 7 | 66 | 29 | 50 | 10 | 33 | 16 | 30 | 7 | 3 | 2 | 8 |
1,727 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMForMultipleChoice | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
import torch
from torch import nn, tensor
from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenCl... | @add_start_docstrings('ErnieM Model with a multiple choice classification head on top (a linear layer on top of\n the pooled output and a softmax) e.g. for RocStories/SWAG tasks.', ERNIE_M_START_DOCSTRING)
class ErnieMForMultipleChoice(ErnieMPreTrainedModel):
def __init__(self, config):
pass
@add_st... | 6 | 1 | 37 | 5 | 29 | 4 | 6 | 0.11 | 1 | 5 | 2 | 0 | 2 | 3 | 2 | 132 | 82 | 10 | 65 | 27 | 45 | 7 | 28 | 15 | 25 | 10 | 3 | 1 | 12 |
1,728 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMForQuestionAnswering | from typing import Optional, Union
from ....utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from torch import nn, tensor
from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MultipleChoiceM... | @add_start_docstrings('ErnieM Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear\n layers on top of the hidden-states output to compute `span start logits` and `span end logits`).', ERNIE_M_START_DOCSTRING)
class ErnieMForQuestionAnswering(ErnieMPreTrainedModel)... | 6 | 1 | 40 | 5 | 29 | 7 | 4 | 0.2 | 1 | 5 | 2 | 0 | 2 | 3 | 2 | 132 | 89 | 10 | 66 | 29 | 44 | 13 | 32 | 16 | 29 | 7 | 3 | 2 | 8 |
1,729 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMForSequenceClassification | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ....cache_utils import Cache
from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifier... | @add_start_docstrings('ErnieM Model transformer with a sequence classification/regression head on top (a linear layer on top of\n the pooled output) e.g. for GLUE tasks.', ERNIE_M_START_DOCSTRING)
class ErnieMForSequenceClassification(ErnieMPreTrainedModel):
def __init__(self, config):
pass
@add_sta... | 6 | 1 | 43 | 4 | 35 | 4 | 7 | 0.09 | 1 | 6 | 2 | 0 | 2 | 5 | 2 | 132 | 94 | 9 | 78 | 29 | 55 | 7 | 36 | 15 | 33 | 12 | 3 | 3 | 14 |
1,730 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMForTokenClassification | from ....cache_utils import Cache
from typing import Optional, Union
from torch import nn, tensor
import torch
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MultipleChoiceModelOu... | @add_start_docstrings('ErnieM Model with a token classification head on top (a linear layer on top of\n the hidden-states output) e.g. for Named-Entity-Recognition (NER) tasks.', ERNIE_M_START_DOCSTRING)
class ErnieMForTokenClassification(ErnieMPreTrainedModel):
def __init__(self, config):
pass
@add... | 6 | 1 | 32 | 4 | 26 | 3 | 4 | 0.08 | 1 | 5 | 2 | 0 | 2 | 4 | 2 | 132 | 73 | 9 | 59 | 27 | 37 | 5 | 23 | 14 | 20 | 5 | 3 | 1 | 7 |
1,731 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMModel | from typing import Optional, Union
from ....utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
import torch
from torch import nn, tensor
from ....modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, Mu... | @add_start_docstrings('The bare ErnieM Model transformer outputting raw hidden-states without any specific head on top.', ERNIE_M_START_DOCSTRING)
class ErnieMModel(ErnieMPreTrainedModel):
def __init__(self, config, add_pooling_layer=True):
pass
def get_input_embeddings(self):
pass
def se... | 9 | 1 | 19 | 2 | 16 | 1 | 4 | 0.08 | 1 | 7 | 4 | 0 | 5 | 4 | 5 | 135 | 107 | 13 | 87 | 34 | 62 | 7 | 47 | 21 | 41 | 14 | 3 | 2 | 20 |
1,732 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMPooler | from torch import nn, tensor
import torch
class ErnieMPooler(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:
fi... |
class ErnieMPooler(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 6 | 0 | 5 | 1 | 1 | 0.2 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 12 | 13 | 1 | 10 | 7 | 7 | 2 | 10 | 7 | 7 | 1 | 1 | 0 | 2 |
1,733 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMPreTrainedModel | from torch import nn, tensor
from .configuration_ernie_m import ErnieMConfig
from ....modeling_utils import PreTrainedModel
class ErnieMPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
... |
class ErnieMPreTrainedModel(PreTrainedModel):
'''
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
'''
def _init_weights(self, module):
'''Initialize the weights'''
pass | 2 | 2 | 15 | 0 | 12 | 3 | 6 | 0.47 | 1 | 0 | 0 | 6 | 1 | 0 | 1 | 130 | 24 | 2 | 15 | 4 | 13 | 7 | 13 | 4 | 11 | 6 | 2 | 2 | 6 |
1,734 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/modeling_ernie_m.py | transformers.models.deprecated.ernie_m.modeling_ernie_m.ErnieMSelfAttention | from ....utils.deprecation import deprecate_kwarg
import math
from torch import nn, tensor
import torch
from typing import Optional, Union
from ....cache_utils import Cache
class ErnieMSelfAttention(nn.Module):
def __init__(self, config, position_embedding_type=None):
super().__init__()
if config.... |
class ErnieMSelfAttention(nn.Module):
def __init__(self, config, position_embedding_type=None):
pass
def transpose_for_scores(self, x: torch.Tensor) -> torch.Tensor:
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: to... | 5 | 0 | 43 | 7 | 31 | 6 | 6 | 0.19 | 1 | 5 | 0 | 0 | 3 | 11 | 3 | 13 | 132 | 22 | 93 | 44 | 80 | 18 | 72 | 35 | 68 | 13 | 1 | 2 | 17 |
1,735 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/ernie_m/tokenization_ernie_m.py | transformers.models.deprecated.ernie_m.tokenization_ernie_m.ErnieMTokenizer | import os
from typing import Any, Optional
import sentencepiece as spm
from ....utils.import_utils import requires
from ....tokenization_utils import PreTrainedTokenizer
import unicodedata
@requires(backends=('sentencepiece',))
class ErnieMTokenizer(PreTrainedTokenizer):
"""
Constructs a Ernie-M tokenizer. It ... | @requires(backends=('sentencepiece',))
class ErnieMTokenizer(PreTrainedTokenizer):
'''
Constructs a Ernie-M tokenizer. It uses the `sentencepiece` tools to cut the words to sub-words.
Args:
sentencepiece_model_file (`str`):
The file path of sentencepiece model.
vocab_file (`str`,... | 25 | 14 | 14 | 1 | 9 | 4 | 3 | 0.5 | 1 | 8 | 0 | 0 | 22 | 7 | 22 | 111 | 365 | 52 | 209 | 80 | 170 | 104 | 167 | 60 | 144 | 17 | 3 | 4 | 67 |
1,736 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/configuration_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.configuration_gptsan_japanese.GPTSanJapaneseConfig | from ....configuration_utils import PretrainedConfig
class GPTSanJapaneseConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`GPTSanJapaneseModel`]. It is used to instantiate
a GPTSANJapanese model according to the specified arguments, defining the model architect... |
class GPTSanJapaneseConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`GPTSanJapaneseModel`]. It is used to instantiate
a GPTSANJapanese model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defau... | 2 | 1 | 59 | 1 | 58 | 0 | 1 | 0.85 | 1 | 1 | 0 | 0 | 1 | 23 | 1 | 33 | 131 | 5 | 68 | 56 | 38 | 58 | 29 | 28 | 27 | 1 | 2 | 0 | 1 |
1,737 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapaneseAttention | from typing import Optional, Union
from ....cache_utils import Cache
import torch.nn as nn
import torch
from .configuration_gptsan_japanese import GPTSanJapaneseConfig
from ....utils.deprecation import deprecate_kwarg
class GPTSanJapaneseAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Ne... |
class GPTSanJapaneseAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, embed_dim: int, num_heads: int, dropout: float=0.0, is_decoder: bool=False, bias: bool=True, is_causal: bool=False, config: Optional[GPTSanJapaneseConfig]=None):
pass
d... | 5 | 2 | 50 | 7 | 35 | 8 | 5 | 0.24 | 1 | 7 | 1 | 0 | 3 | 12 | 3 | 13 | 156 | 23 | 107 | 44 | 86 | 26 | 68 | 27 | 64 | 12 | 1 | 2 | 15 |
1,738 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapaneseBlock | import torch
from typing import Optional, Union
from ....utils.deprecation import deprecate_kwarg
from ....cache_utils import Cache
import torch.nn as nn
class GPTSanJapaneseBlock(nn.Module):
"""
Self Attention and FFN Unit
"""
def __init__(self, config, ext_layer=False):
super().__init__()
... |
class GPTSanJapaneseBlock(nn.Module):
'''
Self Attention and FFN Unit
'''
def __init__(self, config, ext_layer=False):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: Optional[tuple[torch.FloatTensor]], past_key_value... | 4 | 2 | 37 | 5 | 18 | 15 | 3 | 0.92 | 1 | 6 | 3 | 0 | 2 | 2 | 2 | 12 | 80 | 11 | 36 | 19 | 24 | 33 | 18 | 10 | 15 | 4 | 1 | 2 | 6 |
1,739 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapaneseDenseActDense | from ....activations import ACT2FN
from .configuration_gptsan_japanese import GPTSanJapaneseConfig
import torch.nn as nn
class GPTSanJapaneseDenseActDense(nn.Module):
"""
FFN Layer for Switch Transformer and Extra layers
GPTSAN can mix Switch Transformer layers and normal Transformer layers This class is ... |
class GPTSanJapaneseDenseActDense(nn.Module):
'''
FFN Layer for Switch Transformer and Extra layers
GPTSAN can mix Switch Transformer layers and normal Transformer layers This class is used as Expert in Switch
Transformer layers and as FFN in regular Transformer layers. RELU is used in the Switch Trans... | 3 | 2 | 11 | 1 | 7 | 4 | 3 | 0.93 | 1 | 2 | 1 | 0 | 2 | 4 | 2 | 12 | 32 | 5 | 14 | 8 | 11 | 13 | 14 | 8 | 11 | 4 | 1 | 0 | 5 |
1,740 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapaneseForConditionalGeneration | from typing import Optional, Union
import torch.nn as nn
from .configuration_gptsan_japanese import GPTSanJapaneseConfig
from ....cache_utils import Cache
from ....utils import DUMMY_INPUTS, DUMMY_MASK, add_start_docstrings, add_start_docstrings_to_model_forward, is_torch_fx_proxy, logging
from ....modeling_outputs imp... | @add_start_docstrings('The bare GPTSAN-japanese Model with a language modeling head.', GPTSAN_JAPANESE_START_DOCSTRING)
class GPTSanJapaneseForConditionalGeneration(GPTSanJapanesePreTrainedModel):
def __init__(self, config: GPTSanJapaneseConfig):
pass
@add_start_docstrings_to_model_forward(GPTSAN_JAPAN... | 12 | 1 | 20 | 2 | 14 | 5 | 2 | 0.35 | 1 | 9 | 3 | 0 | 11 | 3 | 11 | 143 | 238 | 28 | 155 | 64 | 116 | 55 | 79 | 36 | 67 | 7 | 3 | 2 | 26 |
1,741 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapaneseLayerDenseFF | from .configuration_gptsan_japanese import GPTSanJapaneseConfig
import torch.nn as nn
class GPTSanJapaneseLayerDenseFF(nn.Module):
"""
Extra Transformers Feed Forward layer module.
Parameters:
config : ([`GPTSanJapaneseConfig`]): Model configuration class with all the parameters of the model.
... |
class GPTSanJapaneseLayerDenseFF(nn.Module):
'''
Extra Transformers Feed Forward layer module.
Parameters:
config : ([`GPTSanJapaneseConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the m... | 3 | 2 | 9 | 1 | 4 | 4 | 1 | 1.67 | 1 | 3 | 2 | 0 | 2 | 2 | 2 | 12 | 28 | 4 | 9 | 7 | 6 | 15 | 9 | 7 | 6 | 1 | 1 | 0 | 2 |
1,742 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapaneseLayerSelfAttention | import torch
from ....cache_utils import Cache
from ....utils.deprecation import deprecate_kwarg
import torch.nn as nn
from typing import Optional, Union
class GPTSanJapaneseLayerSelfAttention(nn.Module):
"""
Self Attention and Normalization Unit
"""
def __init__(self, config, has_relative_attention_b... |
class GPTSanJapaneseLayerSelfAttention(nn.Module):
'''
Self Attention and Normalization Unit
'''
def __init__(self, config, has_relative_attention_bias=False):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: Optional[... | 4 | 2 | 39 | 5 | 19 | 17 | 3 | 0.97 | 1 | 4 | 1 | 0 | 2 | 2 | 2 | 12 | 84 | 11 | 38 | 19 | 27 | 37 | 17 | 11 | 14 | 4 | 1 | 1 | 5 |
1,743 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapaneseLayerSparseFF | import torch
import torch.nn as nn
from .configuration_gptsan_japanese import GPTSanJapaneseConfig
class GPTSanJapaneseLayerSparseFF(nn.Module):
"""
Switch Transformers Feed Forward layer module. This is a wrapper around the Mixture of Experts module.
Parameters:
config : ([`GPTSanJapaneseConfig`]... |
class GPTSanJapaneseLayerSparseFF(nn.Module):
'''
Switch Transformers Feed Forward layer module. This is a wrapper around the Mixture of Experts module.
Parameters:
config : ([`GPTSanJapaneseConfig`]): Model configuration class with all the parameters of the model.
Initializing with a c... | 3 | 2 | 12 | 1 | 7 | 5 | 2 | 1.14 | 1 | 3 | 2 | 0 | 2 | 3 | 2 | 12 | 35 | 5 | 14 | 8 | 11 | 16 | 13 | 8 | 10 | 2 | 1 | 1 | 3 |
1,744 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapaneseModel | from .configuration_gptsan_japanese import GPTSanJapaneseConfig
import torch
from ....utils import DUMMY_INPUTS, DUMMY_MASK, add_start_docstrings, add_start_docstrings_to_model_forward, is_torch_fx_proxy, logging
from typing import Optional, Union
from ....modeling_outputs import MoECausalLMOutputWithPast, MoEModelOutp... | @add_start_docstrings('The bare GPTSAN-japanese Model transformer outputting raw hidden-states without any specific head on top.', GPTSAN_JAPANESE_START_DOCSTRING)
class GPTSanJapaneseModel(GPTSanJapanesePreTrainedModel):
def __init__(self, config: GPTSanJapaneseConfig):
pass
def set_input_embeddings(... | 6 | 1 | 60 | 6 | 46 | 9 | 9 | 0.19 | 1 | 10 | 3 | 0 | 4 | 8 | 4 | 136 | 243 | 27 | 187 | 57 | 165 | 35 | 109 | 40 | 104 | 29 | 3 | 4 | 37 |
1,745 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapanesePreTrainedModel | from ....modeling_utils import PreTrainedModel
from .configuration_gptsan_japanese import GPTSanJapaneseConfig
import torch
from ....utils import DUMMY_INPUTS, DUMMY_MASK, add_start_docstrings, add_start_docstrings_to_model_forward, is_torch_fx_proxy, logging
import torch.nn as nn
class GPTSanJapanesePreTrainedModel(P... |
class GPTSanJapanesePreTrainedModel(PreTrainedModel):
'''
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
'''
@property
def dummy_inputs(self):
pass
def _init_weights(self, module):
'''Initialize the w... | 5 | 2 | 29 | 1 | 23 | 5 | 7 | 0.25 | 1 | 7 | 5 | 2 | 3 | 0 | 3 | 132 | 103 | 8 | 77 | 21 | 72 | 19 | 62 | 20 | 58 | 15 | 2 | 2 | 20 |
1,746 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapaneseSparseMLP | from .configuration_gptsan_japanese import GPTSanJapaneseConfig
import torch
import torch.nn as nn
class GPTSanJapaneseSparseMLP(nn.Module):
"""
Implementation of the Switch Transformers Sparse MLP module.
"""
def __init__(self, config: GPTSanJapaneseConfig, expert_class: nn.Module=GPTSanJapaneseDense... |
class GPTSanJapaneseSparseMLP(nn.Module):
'''
Implementation of the Switch Transformers Sparse MLP module.
'''
def __init__(self, config: GPTSanJapaneseConfig, expert_class: nn.Module=GPTSanJapaneseDenseActDense):
pass
def forward(self, hidden_states):
'''
Hold on, this wi... | 3 | 2 | 18 | 4 | 8 | 7 | 2 | 1 | 1 | 6 | 3 | 0 | 2 | 2 | 2 | 12 | 41 | 9 | 16 | 11 | 13 | 16 | 16 | 11 | 13 | 2 | 1 | 1 | 4 |
1,747 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/modeling_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.modeling_gptsan_japanese.GPTSanJapaneseTop1Router | import torch
import torch.nn as nn
from .configuration_gptsan_japanese import GPTSanJapaneseConfig
class GPTSanJapaneseTop1Router(nn.Module):
"""
Router using tokens choose top-1 experts assignment.
This router uses the same mechanism as in Switch Transformer (https://huggingface.co/papers/2101.03961) and... |
class GPTSanJapaneseTop1Router(nn.Module):
'''
Router using tokens choose top-1 experts assignment.
This router uses the same mechanism as in Switch Transformer (https://huggingface.co/papers/2101.03961) and V-MoE
(https://huggingface.co/papers/2106.05974): tokens choose their top experts. Items are so... | 5 | 4 | 19 | 2 | 7 | 10 | 2 | 1.53 | 1 | 3 | 1 | 0 | 4 | 7 | 4 | 14 | 91 | 15 | 30 | 18 | 25 | 46 | 30 | 18 | 25 | 2 | 1 | 1 | 6 |
1,748 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/tokenization_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.tokenization_gptsan_japanese.GPTSanJapaneseTokenizer | import os
from ....tokenization_utils import PreTrainedTokenizer
from ....utils import PaddingStrategy, logging
from ....tokenization_utils_base import BatchEncoding, PreTokenizedInput, PreTokenizedInputPair, TextInput, TextInputPair, TruncationStrategy
from typing import Optional, Union
import json
class GPTSanJapane... |
class GPTSanJapaneseTokenizer(PreTrainedTokenizer):
'''
This tokenizer is based on GPTNeoXJapaneseTokenizer and has the following modifications
- Decoding byte0~byte255 tokens correctly
- Added bagofword token handling
- Return token_type_ids for Prefix-LM model
The bagofword token represents a... | 13 | 5 | 19 | 1 | 16 | 2 | 4 | 0.48 | 1 | 12 | 3 | 0 | 11 | 8 | 11 | 100 | 304 | 32 | 184 | 68 | 137 | 89 | 92 | 31 | 80 | 15 | 3 | 4 | 44 |
1,749 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/gptsan_japanese/tokenization_gptsan_japanese.py | transformers.models.deprecated.gptsan_japanese.tokenization_gptsan_japanese.SubWordJapaneseTokenizer | import sys
import re
import numpy as np
class SubWordJapaneseTokenizer:
"""
This tokenizer is based on GPTNeoXJapaneseTokenizer and has the following modifications
- Decoding byte0~byte255 tokens correctly
- Added bagofword token handling
https://github.com/tanreinama/Japanese-BPEEncoder_V2 This t... |
class SubWordJapaneseTokenizer:
'''
This tokenizer is based on GPTNeoXJapaneseTokenizer and has the following modifications
- Decoding byte0~byte255 tokens correctly
- Added bagofword token handling
https://github.com/tanreinama/Japanese-BPEEncoder_V2 This tokenizer class is under MIT License accor... | 8 | 1 | 17 | 0 | 17 | 1 | 3 | 0.26 | 0 | 3 | 0 | 0 | 5 | 11 | 5 | 5 | 133 | 14 | 98 | 34 | 90 | 25 | 83 | 34 | 75 | 13 | 0 | 4 | 24 |
1,750 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/collating_graphormer.py | transformers.models.deprecated.graphormer.collating_graphormer.GraphormerDataCollator | import numpy as np
from typing import Any
import torch
from ....utils import is_cython_available, requires_backends
from collections.abc import Mapping
class GraphormerDataCollator:
def __init__(self, spatial_pos_max=20, on_the_fly_processing=False):
if not is_cython_available():
raise ImportE... |
class GraphormerDataCollator:
def __init__(self, spatial_pos_max=20, on_the_fly_processing=False):
pass
def __call__(self, features: list[dict]) -> dict[str, Any]:
pass | 3 | 0 | 30 | 5 | 25 | 2 | 5 | 0.08 | 0 | 6 | 0 | 0 | 2 | 2 | 2 | 2 | 62 | 11 | 51 | 15 | 48 | 4 | 43 | 15 | 40 | 8 | 0 | 2 | 10 |
1,751 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/configuration_graphormer.py | transformers.models.deprecated.graphormer.configuration_graphormer.GraphormerConfig | from ....configuration_utils import PretrainedConfig
from typing import Optional
class GraphormerConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`~GraphormerModel`]. It is used to instantiate an
Graphormer model according to the specified arguments, defining t... |
class GraphormerConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`~GraphormerModel`]. It is used to instantiate an
Graphormer model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will y... | 2 | 1 | 86 | 2 | 82 | 3 | 1 | 1.14 | 1 | 5 | 0 | 0 | 1 | 35 | 1 | 33 | 192 | 11 | 85 | 79 | 43 | 97 | 40 | 39 | 38 | 1 | 2 | 0 | 1 |
1,752 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/modeling_graphormer.py | transformers.models.deprecated.graphormer.modeling_graphormer.GraphormerDecoderHead | import torch
import torch.nn as nn
class GraphormerDecoderHead(nn.Module):
def __init__(self, embedding_dim: int, num_classes: int):
super().__init__()
'num_classes should be 1 for regression, or the number of classes for classification'
self.lm_output_learned_bias = nn.Parameter(torch.zer... |
class GraphormerDecoderHead(nn.Module):
def __init__(self, embedding_dim: int, num_classes: int):
pass
def forward(self, input_nodes: torch.Tensor, **unused) -> torch.Tensor:
pass | 3 | 0 | 5 | 0 | 5 | 1 | 1 | 0.1 | 1 | 3 | 0 | 0 | 2 | 3 | 2 | 12 | 12 | 1 | 10 | 6 | 7 | 1 | 10 | 6 | 7 | 1 | 1 | 0 | 2 |
1,753 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/modeling_graphormer.py | transformers.models.deprecated.graphormer.modeling_graphormer.GraphormerForGraphClassification | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
import torch.nn as nn
from .configuration_graphormer import GraphormerConfig
from ....modeling_outputs import BaseModelOutputWithNoAttention, SequenceClassifierOutput
from typing import Optional, Union
import torch
class GraphormerForGraphClassification... |
class GraphormerForGraphClassification(GraphormerPreTrainedModel):
'''
This model can be used for graph-level classification or regression tasks.
It can be trained on
- regression (by setting config.num_classes to 1); there should be one float-type label per graph
- one task classification (by sett... | 3 | 1 | 29 | 3 | 25 | 2 | 4 | 0.25 | 1 | 8 | 4 | 0 | 2 | 5 | 2 | 134 | 70 | 9 | 51 | 27 | 36 | 13 | 28 | 15 | 25 | 6 | 3 | 2 | 7 |
1,754 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/modeling_graphormer.py | transformers.models.deprecated.graphormer.modeling_graphormer.GraphormerGraphAttnBias | import torch
from .configuration_graphormer import GraphormerConfig
import torch.nn as nn
class GraphormerGraphAttnBias(nn.Module):
"""
Compute attention bias for each head.
"""
def __init__(self, config: GraphormerConfig):
super().__init__()
self.num_heads = config.num_attention_heads... |
class GraphormerGraphAttnBias(nn.Module):
'''
Compute attention bias for each head.
'''
def __init__(self, config: GraphormerConfig):
pass
def forward(self, input_nodes: torch.LongTensor, attn_bias: torch.Tensor, spatial_pos: torch.LongTensor, input_edges: torch.LongTensor, attn_edge_type... | 3 | 1 | 37 | 6 | 27 | 6 | 3 | 0.27 | 1 | 3 | 1 | 0 | 2 | 7 | 2 | 12 | 80 | 13 | 55 | 24 | 45 | 15 | 37 | 17 | 34 | 3 | 1 | 2 | 5 |
1,755 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/modeling_graphormer.py | transformers.models.deprecated.graphormer.modeling_graphormer.GraphormerGraphEncoder | from .configuration_graphormer import GraphormerConfig
import torch.nn as nn
import torch
from typing import Optional, Union
class GraphormerGraphEncoder(nn.Module):
def __init__(self, config: GraphormerConfig):
super().__init__()
self.dropout_module = torch.nn.Dropout(p=config.dropout, inplace=Fa... |
class GraphormerGraphEncoder(nn.Module):
def __init__(self, config: GraphormerConfig):
pass
def forward(self, input_nodes: torch.LongTensor, input_edges: torch.LongTensor, attn_bias: torch.Tensor, in_degree: torch.LongTensor, out_degree: torch.LongTensor, spatial_pos: torch.LongTensor, attn_edge_type... | 3 | 0 | 57 | 11 | 45 | 1 | 10 | 0.02 | 1 | 10 | 5 | 0 | 2 | 12 | 2 | 12 | 115 | 23 | 90 | 40 | 74 | 2 | 63 | 26 | 60 | 11 | 1 | 3 | 20 |
1,756 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/modeling_graphormer.py | transformers.models.deprecated.graphormer.modeling_graphormer.GraphormerGraphEncoderLayer | from typing import Optional, Union
from .configuration_graphormer import GraphormerConfig
from ....activations import ACT2FN
import torch.nn as nn
import torch
class GraphormerGraphEncoderLayer(nn.Module):
def __init__(self, config: GraphormerConfig) -> None:
super().__init__()
self.embedding_dim ... |
class GraphormerGraphEncoderLayer(nn.Module):
def __init__(self, config: GraphormerConfig) -> None:
pass
def build_fc(self, input_dim: int, output_dim: int, q_noise: float, qn_block_size: int) -> Union[nn.Module, nn.Linear, nn.Embedding, nn.Conv2d]:
pass
def forward(self, input_nodes: to... | 4 | 1 | 27 | 3 | 21 | 3 | 2 | 0.13 | 1 | 6 | 2 | 0 | 3 | 13 | 3 | 13 | 84 | 12 | 64 | 27 | 52 | 8 | 38 | 19 | 34 | 5 | 1 | 1 | 7 |
1,757 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/modeling_graphormer.py | transformers.models.deprecated.graphormer.modeling_graphormer.GraphormerGraphNodeFeature | from .configuration_graphormer import GraphormerConfig
import torch
import torch.nn as nn
class GraphormerGraphNodeFeature(nn.Module):
"""
Compute node features for each node in the graph.
"""
def __init__(self, config: GraphormerConfig):
super().__init__()
self.num_heads = config.num_... |
class GraphormerGraphNodeFeature(nn.Module):
'''
Compute node features for each node in the graph.
'''
def __init__(self, config: GraphormerConfig):
pass
def forward(self, input_nodes: torch.LongTensor, in_degree: torch.LongTensor, out_degree: torch.LongTensor) -> torch.Tensor:
pa... | 3 | 1 | 17 | 3 | 14 | 1 | 1 | 0.18 | 1 | 3 | 1 | 0 | 2 | 6 | 2 | 12 | 39 | 8 | 28 | 18 | 20 | 5 | 15 | 13 | 12 | 1 | 1 | 0 | 2 |
1,758 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/modeling_graphormer.py | transformers.models.deprecated.graphormer.modeling_graphormer.GraphormerModel | import torch
from .configuration_graphormer import GraphormerConfig
from ....activations import ACT2FN
from ....modeling_outputs import BaseModelOutputWithNoAttention, SequenceClassifierOutput
from typing import Optional, Union
import torch.nn as nn
class GraphormerModel(GraphormerPreTrainedModel):
"""The Graphorm... |
class GraphormerModel(GraphormerPreTrainedModel):
'''The Graphormer model is a graph-encoder model.
It goes from a graph to its representation. If you want to use the model for a downstream classification task, use
GraphormerForGraphClassification instead. For any other downstream task, feel free to add a ... | 5 | 2 | 15 | 3 | 11 | 1 | 2 | 0.23 | 1 | 8 | 3 | 0 | 4 | 7 | 4 | 136 | 69 | 16 | 43 | 26 | 25 | 10 | 28 | 13 | 23 | 5 | 3 | 1 | 8 |
1,759 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/modeling_graphormer.py | transformers.models.deprecated.graphormer.modeling_graphormer.GraphormerMultiheadAttention | from typing import Optional, Union
import torch.nn as nn
import torch
import math
from .configuration_graphormer import GraphormerConfig
class GraphormerMultiheadAttention(nn.Module):
"""Multi-headed attention.
See "Attention Is All You Need" for more details.
"""
def __init__(self, config: Graphorme... |
class GraphormerMultiheadAttention(nn.Module):
'''Multi-headed attention.
See "Attention Is All You Need" for more details.
'''
def __init__(self, config: GraphormerConfig):
pass
def reset_parameters(self):
pass
def forward(self, query: torch.LongTensor, key: Optional[torch.T... | 5 | 2 | 45 | 6 | 33 | 6 | 8 | 0.19 | 1 | 9 | 1 | 0 | 4 | 14 | 4 | 14 | 188 | 30 | 134 | 40 | 118 | 25 | 97 | 29 | 92 | 22 | 1 | 3 | 32 |
1,760 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/modeling_graphormer.py | transformers.models.deprecated.graphormer.modeling_graphormer.GraphormerPreTrainedModel | import torch.nn as nn
import torch
from ....modeling_utils import PreTrainedModel
from typing import Optional, Union
from .configuration_graphormer import GraphormerConfig
class GraphormerPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloa... |
class GraphormerPreTrainedModel(PreTrainedModel):
'''
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
'''
def normal_(self, data: torch.Tensor):
pass
def init_graphormer_params(self, module: Union[nn.Linear, nn.E... | 4 | 3 | 18 | 0 | 14 | 3 | 6 | 0.27 | 1 | 3 | 2 | 2 | 3 | 0 | 3 | 132 | 66 | 5 | 48 | 13 | 39 | 13 | 38 | 8 | 34 | 10 | 2 | 2 | 17 |
1,761 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/graphormer/modeling_graphormer.py | transformers.models.deprecated.graphormer.modeling_graphormer.LayerDropModuleList | import torch
from collections.abc import Iterable, Iterator
import torch.nn as nn
from typing import Optional, Union
class LayerDropModuleList(nn.ModuleList):
"""
From:
https://github.com/facebookresearch/fairseq/blob/dd0079bde7f678b0cd0715cbd0ae68d661b7226d/fairseq/modules/layer_drop.py
A LayerDrop im... |
class LayerDropModuleList(nn.ModuleList):
'''
From:
https://github.com/facebookresearch/fairseq/blob/dd0079bde7f678b0cd0715cbd0ae68d661b7226d/fairseq/modules/layer_drop.py
A LayerDrop implementation based on [`torch.nn.ModuleList`]. LayerDrop as described in
https://huggingface.co/papers/1909.11556... | 3 | 1 | 4 | 0 | 4 | 0 | 2 | 2.33 | 1 | 3 | 0 | 0 | 2 | 1 | 2 | 2 | 36 | 6 | 9 | 6 | 6 | 21 | 9 | 6 | 6 | 3 | 1 | 2 | 4 |
1,762 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/configuration_jukebox.py | transformers.models.deprecated.jukebox.configuration_jukebox.JukeboxConfig | from ....configuration_utils import PretrainedConfig
class JukeboxConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`JukeboxModel`].
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
documentation... |
class JukeboxConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`JukeboxModel`].
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
documentation from [`PretrainedConfig`] for more information. Insta... | 5 | 2 | 20 | 2 | 15 | 3 | 2 | 1.06 | 1 | 4 | 2 | 0 | 2 | 10 | 3 | 35 | 120 | 19 | 49 | 31 | 32 | 52 | 32 | 18 | 28 | 5 | 2 | 3 | 7 |
1,763 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/configuration_jukebox.py | transformers.models.deprecated.jukebox.configuration_jukebox.JukeboxPriorConfig | from typing import Union
from ....configuration_utils import PretrainedConfig
import os
class JukeboxPriorConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`JukeboxPrior`]. It is used to instantiate a
`JukeboxPrior` according to the specified arguments, ... |
class JukeboxPriorConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`JukeboxPrior`]. It is used to instantiate a
`JukeboxPrior` according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults... | 4 | 1 | 55 | 2 | 52 | 1 | 3 | 0.95 | 1 | 2 | 0 | 0 | 1 | 42 | 2 | 34 | 227 | 11 | 111 | 96 | 60 | 105 | 56 | 48 | 53 | 3 | 2 | 1 | 5 |
1,764 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/configuration_jukebox.py | transformers.models.deprecated.jukebox.configuration_jukebox.JukeboxVQVAEConfig | from ....configuration_utils import PretrainedConfig
import os
from typing import Union
class JukeboxVQVAEConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`JukeboxVQVAE`]. It is used to instantiate a
`JukeboxVQVAE` according to the specified arguments, defining... |
class JukeboxVQVAEConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`JukeboxVQVAE`]. It is used to instantiate a
`JukeboxVQVAE` according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield ... | 4 | 1 | 31 | 3 | 28 | 1 | 2 | 0.91 | 1 | 2 | 0 | 0 | 1 | 20 | 2 | 34 | 121 | 10 | 58 | 49 | 31 | 53 | 31 | 25 | 28 | 3 | 2 | 1 | 4 |
1,765 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxAttention | from torch import nn
import torch.nn.functional as F
import torch
class JukeboxAttention(nn.Module):
def __init__(self, config, n_ctx, attn_func='dense_attn'):
super().__init__()
self.embed_dim = config.hidden_size
self.n_heads = config.n_heads
self.dropout = config.attn_dropout
... |
class JukeboxAttention(nn.Module):
def __init__(self, config, n_ctx, attn_func='dense_attn'):
pass
def _attn(self, query_states, key_states, value_states, sample):
pass
def merge_heads(self, hidden_states):
pass
def split_heads(self, hidden_states, is_key=False):
pas... | 25 | 1 | 15 | 1 | 14 | 1 | 3 | 0.06 | 1 | 5 | 1 | 0 | 23 | 25 | 23 | 33 | 372 | 45 | 318 | 103 | 293 | 19 | 269 | 102 | 245 | 6 | 1 | 3 | 61 |
1,766 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxBlock | from torch import nn
class JukeboxBlock(nn.Module):
def __init__(self, config, n_ctx, attn_func='dense_attn'):
super().__init__()
self.width = config.hidden_size
self.attn = JukeboxAttention(config, n_ctx, attn_func=attn_func)
self.layer_norm_0 = JukeboxLayerNorm(config.hidden_size... |
class JukeboxBlock(nn.Module):
def __init__(self, config, n_ctx, attn_func='dense_attn'):
pass
def forward(self, hidden_states, last_encoder_hidden_states, sample=False):
pass | 3 | 0 | 11 | 1 | 10 | 0 | 2 | 0 | 1 | 4 | 3 | 0 | 2 | 7 | 2 | 12 | 24 | 3 | 21 | 13 | 18 | 0 | 20 | 13 | 17 | 2 | 1 | 1 | 4 |
1,767 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxBottleneck | from torch import nn
class JukeboxBottleneck(nn.Module):
def __init__(self, config, levels):
super().__init__()
self.levels = levels
self.level_blocks = nn.ModuleList()
for level in range(self.levels):
self.level_blocks.append(JukeboxBottleneckBlock(config))
def en... |
class JukeboxBottleneck(nn.Module):
def __init__(self, config, levels):
pass
def encode(self, raw_audio):
pass
def decode(self, music_tokens, start_level=0, end_level=None):
pass
def forward(self, input_audio):
pass | 5 | 0 | 9 | 0 | 9 | 1 | 2 | 0.06 | 1 | 4 | 1 | 0 | 4 | 2 | 4 | 14 | 40 | 3 | 35 | 15 | 30 | 2 | 29 | 15 | 24 | 4 | 1 | 2 | 9 |
1,768 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxBottleneckBlock | from torch import nn
from .configuration_jukebox import ATTENTION_PATTERNS, JukeboxConfig, JukeboxPriorConfig, JukeboxVQVAEConfig
import numpy as np
import torch
import torch.nn.functional as F
class JukeboxBottleneckBlock(nn.Module):
def __init__(self, config: JukeboxVQVAEConfig):
super().__init__()
... |
class JukeboxBottleneckBlock(nn.Module):
def __init__(self, config: JukeboxVQVAEConfig):
pass
def _tile(self, hidden_states):
pass
def init_codebook(self, hidden_states):
pass
def update_codebook(self, hidden_states, latent_states):
pass
def preprocess(self, hid... | 12 | 0 | 13 | 2 | 10 | 2 | 1 | 0.21 | 1 | 3 | 1 | 0 | 11 | 8 | 11 | 21 | 152 | 28 | 107 | 56 | 95 | 22 | 95 | 56 | 83 | 3 | 1 | 1 | 16 |
1,769 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxConditionalAutoregressive | from ....utils.logging import tqdm
from torch import nn
import torch.nn.functional as F
import torch
import numpy as np
class JukeboxConditionalAutoregressive(nn.Module):
def __init__(self, config, n_ctx=None, embed_dim=None, audio_conditioning=False, metadata_conditioning=False, is_encoder=False):
"""
... |
class JukeboxConditionalAutoregressive(nn.Module):
def __init__(self, config, n_ctx=None, embed_dim=None, audio_conditioning=False, metadata_conditioning=False, is_encoder=False):
'''
Autoregressive model on either lyric tokens or music tokens, or both. The attention pattern should be properly
... | 7 | 2 | 54 | 5 | 42 | 8 | 8 | 0.19 | 1 | 6 | 2 | 0 | 6 | 18 | 6 | 16 | 328 | 37 | 254 | 100 | 206 | 47 | 174 | 59 | 167 | 16 | 1 | 4 | 45 |
1,770 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxConv1D | from torch import nn
import torch.nn.functional as F
import torch
class JukeboxConv1D(nn.Module):
def __init__(self, input_width, output_width):
super().__init__()
self.input_width = input_width
self.output_width = output_width
weight = torch.empty(input_width, output_width)
... |
class JukeboxConv1D(nn.Module):
def __init__(self, input_width, output_width):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 9 | 0 | 9 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 4 | 2 | 12 | 19 | 1 | 18 | 10 | 15 | 0 | 14 | 10 | 11 | 1 | 1 | 0 | 2 |
1,771 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxDecoder | from torch import nn
class JukeboxDecoder(nn.Module):
def __init__(self, config, hidden_dim, depth, levels, downs_t, strides_t):
super().__init__()
self.levels = levels
self.level_blocks = nn.ModuleList()
for level, down_t, stride_t in zip(list(range(self.levels)), downs_t, strides... |
class JukeboxDecoder(nn.Module):
def __init__(self, config, hidden_dim, depth, levels, downs_t, strides_t):
pass
def forward(self, hidden_states, all_levels=True):
pass | 3 | 0 | 12 | 2 | 9 | 1 | 3 | 0.05 | 1 | 6 | 1 | 0 | 2 | 3 | 2 | 12 | 25 | 5 | 19 | 10 | 16 | 1 | 17 | 10 | 14 | 3 | 1 | 2 | 5 |
1,772 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxDecoderConvBock | from torch import nn
class JukeboxDecoderConvBock(nn.Module):
def __init__(self, config, embed_dim, hidden_dim, depth, down_t, stride_t, reverse_dilation=True):
self.embed_dim = embed_dim
self.hidden_dim = hidden_dim
super().__init__()
blocks = []
if down_t > 0:
... |
class JukeboxDecoderConvBock(nn.Module):
def __init__(self, config, embed_dim, hidden_dim, depth, down_t, stride_t, reverse_dilation=True):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 11 | 0 | 11 | 0 | 3 | 0 | 1 | 3 | 1 | 0 | 2 | 4 | 2 | 12 | 24 | 1 | 23 | 12 | 20 | 0 | 19 | 12 | 16 | 4 | 1 | 2 | 6 |
1,773 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxEncoder | from torch import nn
class JukeboxEncoder(nn.Module):
def __init__(self, config, width, depth, levels, downs_t, strides_t):
super().__init__()
self.levels = levels
self.level_blocks = nn.ModuleList()
iterator = zip(list(range(self.levels)), downs_t, strides_t)
for i, down_t... |
class JukeboxEncoder(nn.Module):
def __init__(self, config, width, depth, levels, downs_t, strides_t):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 11 | 2 | 9 | 1 | 3 | 0.05 | 1 | 5 | 1 | 0 | 2 | 2 | 2 | 12 | 24 | 4 | 19 | 10 | 16 | 1 | 15 | 10 | 12 | 3 | 1 | 1 | 5 |
1,774 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxEncoderConvBlock | from torch import nn
class JukeboxEncoderConvBlock(nn.Module):
def __init__(self, config, embed_dim, hidden_dim, depth, down_t, stride_t):
super().__init__()
blocks = []
filter_t = stride_t * 2
pad_t = stride_t // 2
if down_t > 0:
for i in range(down_t):
... |
class JukeboxEncoderConvBlock(nn.Module):
def __init__(self, config, embed_dim, hidden_dim, depth, down_t, stride_t):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 8 | 0 | 8 | 0 | 3 | 0 | 1 | 3 | 1 | 0 | 2 | 2 | 2 | 12 | 18 | 1 | 17 | 10 | 14 | 0 | 17 | 10 | 14 | 4 | 1 | 2 | 6 |
1,775 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxLabelConditioner | from torch import nn
class JukeboxLabelConditioner(nn.Module):
def __init__(self, config, include_time_signal):
super().__init__()
embed_dim = config.hidden_size
timing_dims = config.timing_dims
sampling_rate = config.sampling_rate
nb_genres, nb_artists = config.metadata_di... |
class JukeboxLabelConditioner(nn.Module):
def __init__(self, config, include_time_signal):
pass
def forward(self, metadata):
pass | 3 | 0 | 26 | 2 | 23 | 2 | 2 | 0.07 | 1 | 2 | 1 | 0 | 2 | 7 | 2 | 12 | 54 | 5 | 46 | 29 | 43 | 3 | 37 | 29 | 34 | 2 | 1 | 1 | 4 |
1,776 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxLayerNorm | import numpy as np
from torch.nn import LayerNorm as FusedLayerNorm
import torch.nn.functional as F
class JukeboxLayerNorm(FusedLayerNorm):
def __init__(self, normalized_shape, eps=1e-05, elementwise_affine=True):
super().__init__(normalized_shape, eps=eps, elementwise_affine=elementwise_affine)
s... |
class JukeboxLayerNorm(FusedLayerNorm):
def __init__(self, normalized_shape, eps=1e-05, elementwise_affine=True):
pass
def forward(self, input):
pass | 3 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 2 | 11 | 1 | 10 | 5 | 7 | 0 | 9 | 5 | 6 | 2 | 1 | 1 | 3 |
1,777 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxLayerStack | from torch import nn
from .configuration_jukebox import ATTENTION_PATTERNS, JukeboxConfig, JukeboxPriorConfig, JukeboxVQVAEConfig
class JukeboxLayerStack(nn.Module):
def __init__(self, config, n_ctx):
super().__init__()
self.n_ctx = n_ctx
self.width = config.hidden_size
self.num_la... |
class JukeboxLayerStack(nn.Module):
def __init__(self, config, n_ctx):
pass
def set_record_attn(self, record_attn):
'''
Makes forward prop dump self-attention softmaxes to self.saved_attn_weights.
Args:
record_attn (`Union[bool,set]`):
Either a set ... | 6 | 1 | 12 | 1 | 9 | 2 | 3 | 0.25 | 1 | 5 | 1 | 0 | 4 | 10 | 4 | 14 | 58 | 9 | 40 | 21 | 34 | 10 | 37 | 21 | 31 | 4 | 1 | 2 | 14 |
1,778 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxMLP | from torch import nn
from ....activations import ACT2FN
class JukeboxMLP(nn.Module):
def __init__(self, config):
super().__init__()
embed_dim = config.hidden_size
hidden_dim = int(config.mlp_multiplier * embed_dim)
self.c_fc = JukeboxConv1D(embed_dim, hidden_dim)
self.c_pro... |
class JukeboxMLP(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 8 | 1 | 7 | 1 | 1 | 0.07 | 1 | 3 | 1 | 0 | 2 | 4 | 2 | 12 | 18 | 2 | 15 | 9 | 12 | 1 | 15 | 9 | 12 | 1 | 1 | 0 | 2 |
1,779 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxModel | from torch import nn
from ....utils.logging import tqdm
import os
import torch
from ....utils import add_start_docstrings, logging
import torch.nn.functional as F
@add_start_docstrings('The bare JUKEBOX Model used for music generation. 4 sampling techniques are supported : `primed_sample`, `upsample`,\n `continue_s... | @add_start_docstrings('The bare JUKEBOX Model used for music generation. 4 sampling techniques are supported : `primed_sample`, `upsample`,\n `continue_sample` and `ancestral_sample`. It does not have a `forward` method as the training is not end to end. If\n you want to fine-tune the model, it is recommended to ... | 20 | 3 | 23 | 2 | 14 | 7 | 2 | 0.41 | 1 | 9 | 2 | 0 | 13 | 3 | 13 | 144 | 371 | 44 | 233 | 129 | 155 | 95 | 123 | 64 | 109 | 9 | 3 | 4 | 31 |
1,780 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxMusicTokenConditioner | from torch import nn
class JukeboxMusicTokenConditioner(nn.Module):
"""
The `JukeboxMusicTokenConditioner` takes music tokens as an input (corresponding to the codes of the VQVAE's
codebook) and upsamples it using a single layer of decoder convolution block (the same is used in the VQVAE).
"""
def... |
class JukeboxMusicTokenConditioner(nn.Module):
'''
The `JukeboxMusicTokenConditioner` takes music tokens as an input (corresponding to the codes of the VQVAE's
codebook) and upsamples it using a single layer of decoder convolution block (the same is used in the VQVAE).
'''
def __init__(self, confi... | 3 | 2 | 18 | 1 | 13 | 5 | 2 | 0.54 | 1 | 3 | 2 | 0 | 2 | 3 | 2 | 12 | 43 | 4 | 26 | 7 | 23 | 14 | 18 | 7 | 15 | 2 | 1 | 1 | 3 |
1,781 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxPositionalEmbedding | from torch import nn
import torch.nn.functional as F
import torch
class JukeboxPositionalEmbedding(nn.Module):
def __init__(self, embed_dim, width):
super().__init__()
self.pos_emb = nn.Parameter(torch.empty((embed_dim, width)))
def forward(self):
pos_emb = self.pos_emb
return... |
class JukeboxPositionalEmbedding(nn.Module):
def __init__(self, embed_dim, width):
pass
def forward(self):
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 12 | 8 | 1 | 7 | 5 | 4 | 0 | 7 | 5 | 4 | 1 | 1 | 0 | 2 |
1,782 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxPreTrainedModel | from .configuration_jukebox import ATTENTION_PATTERNS, JukeboxConfig, JukeboxPriorConfig, JukeboxVQVAEConfig
from ....modeling_utils import PreTrainedModel
class JukeboxPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pr... |
class JukeboxPreTrainedModel(PreTrainedModel):
'''
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
'''
def _init_weights(self, module):
pass
def __init__(self, *inputs, **kwargs):
pass | 3 | 1 | 3 | 0 | 3 | 0 | 2 | 0.44 | 1 | 3 | 2 | 1 | 2 | 0 | 2 | 131 | 16 | 3 | 9 | 6 | 6 | 4 | 9 | 6 | 6 | 2 | 2 | 1 | 3 |
1,783 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxPrior | from torch import nn
from .configuration_jukebox import ATTENTION_PATTERNS, JukeboxConfig, JukeboxPriorConfig, JukeboxVQVAEConfig
from typing import Optional
import numpy as np
from ....modeling_utils import PreTrainedModel
import torch
import torch.nn.functional as F
class JukeboxPrior(PreTrainedModel):
"""
T... |
class JukeboxPrior(PreTrainedModel):
'''
The JukeboxPrior class, which is a wrapper around the various conditioning and the transformer. JukeboxPrior can be
seen as language models trained on music. They model the next `music token` prediction task. If a (lyric) `encoderù
is defined, it also models the... | 17 | 14 | 28 | 2 | 21 | 6 | 4 | 0.34 | 1 | 17 | 9 | 0 | 16 | 29 | 16 | 145 | 492 | 46 | 334 | 113 | 298 | 115 | 204 | 94 | 187 | 11 | 2 | 3 | 61 |
1,784 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxRangeEmbedding | from torch import nn
import torch.nn.functional as F
import torch
class JukeboxRangeEmbedding(nn.Module):
"""
The `JukeboxRangeEmbedding` interpolate the given [pos_start, pos_end] to obtain an equivalent of time positional
embedding of length `n_ctx`.
Binning process : For each pos in position tensor... |
class JukeboxRangeEmbedding(nn.Module):
'''
The `JukeboxRangeEmbedding` interpolate the given [pos_start, pos_end] to obtain an equivalent of time positional
embedding of length `n_ctx`.
Binning process : For each pos in position tensor, find its bin [start,end) mapped to [0,1,...,bins-1] [start,end)
... | 3 | 1 | 18 | 2 | 14 | 2 | 4 | 0.38 | 1 | 3 | 0 | 0 | 2 | 6 | 2 | 12 | 46 | 6 | 29 | 13 | 26 | 11 | 26 | 13 | 23 | 6 | 1 | 2 | 7 |
1,785 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxResConv1DBlock | from torch import nn
class JukeboxResConv1DBlock(nn.Module):
def __init__(self, config, conv_width, depth=1, res_scale=1.0):
super().__init__()
hidden_dim = config.res_convolution_multiplier * conv_width
dilation = config.res_dilation_growth_rate ** depth
padding = dilation
... |
class JukeboxResConv1DBlock(nn.Module):
def __init__(self, config, conv_width, depth=1, res_scale=1.0):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 9 | 1 | 8 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 4 | 2 | 12 | 19 | 2 | 17 | 11 | 14 | 0 | 17 | 11 | 14 | 1 | 1 | 0 | 2 |
1,786 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxResnet1D | from torch import nn
import math
class JukeboxResnet1D(nn.Module):
def __init__(self, config, conv_width, n_depth, reverse_dilation=False):
super().__init__()
self.dilation_cycle = config.res_dilation_cycle
res_scale = 1.0 if not config.conv_res_scale else 1.0 / math.sqrt(n_depth)
... |
class JukeboxResnet1D(nn.Module):
def __init__(self, config, conv_width, n_depth, reverse_dilation=False):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 9 | 1 | 8 | 0 | 4 | 0 | 1 | 3 | 1 | 0 | 2 | 2 | 2 | 12 | 19 | 3 | 16 | 10 | 13 | 0 | 16 | 10 | 13 | 5 | 1 | 1 | 7 |
1,787 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/modeling_jukebox.py | transformers.models.deprecated.jukebox.modeling_jukebox.JukeboxVQVAE | from torch import nn
from .configuration_jukebox import ATTENTION_PATTERNS, JukeboxConfig, JukeboxPriorConfig, JukeboxVQVAEConfig
import numpy as np
from ....modeling_utils import PreTrainedModel
import torch
from ....utils import add_start_docstrings, logging
import torch.nn.functional as F
@add_start_docstrings('The... | @add_start_docstrings('The Hierarchical VQ-VAE model used in Jukebox. This model follows the Hierarchical VQVAE paper from [Will Williams, Sam\nRinger, Tom Ash, John Hughes, David MacLeod, Jamie Dougherty](https://huggingface.co/papers/2002.08111).\n\n ', JUKEBOX_START_DOCSTRING)
class JukeboxVQVAE(PreTrainedModel):... | 10 | 3 | 22 | 2 | 13 | 6 | 3 | 0.47 | 1 | 11 | 6 | 0 | 8 | 11 | 8 | 137 | 183 | 24 | 109 | 58 | 100 | 51 | 95 | 58 | 86 | 7 | 2 | 2 | 24 |
1,788 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/jukebox/tokenization_jukebox.py | transformers.models.deprecated.jukebox.tokenization_jukebox.JukeboxTokenizer | from typing import Any, Optional, Union
import unicodedata
from json.encoder import INFINITY
import json
from ....utils.generic import _is_numpy
from ....utils import TensorType, is_torch_available, logging
import regex
import os
from ....tokenization_utils_base import BatchEncoding
from ....tokenization_utils import A... |
class JukeboxTokenizer(PreTrainedTokenizer):
'''
Constructs a Jukebox tokenizer. Jukebox can be conditioned on 3 different inputs :
- Artists, unique ids are associated to each artist from the provided dictionary.
- Genres, unique ids are associated to each genre from the provided dictionary.
... | 16 | 11 | 21 | 2 | 13 | 6 | 3 | 0.63 | 1 | 10 | 1 | 0 | 14 | 13 | 14 | 103 | 363 | 57 | 189 | 73 | 156 | 120 | 136 | 56 | 118 | 11 | 3 | 2 | 37 |
1,789 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/configuration_mctct.py | transformers.models.deprecated.mctct.configuration_mctct.MCTCTConfig | from ....configuration_utils import PretrainedConfig
class MCTCTConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`MCTCTModel`]. It is used to instantiate an
M-CTC-T model according to the specified arguments, defining the model architecture. Instantiating a con... |
class MCTCTConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`MCTCTModel`]. It is used to instantiate an
M-CTC-T model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar... | 2 | 1 | 67 | 2 | 64 | 1 | 2 | 1.21 | 1 | 3 | 0 | 0 | 1 | 26 | 1 | 33 | 158 | 12 | 66 | 58 | 35 | 80 | 32 | 29 | 30 | 2 | 2 | 1 | 2 |
1,790 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/feature_extraction_mctct.py | transformers.models.deprecated.mctct.feature_extraction_mctct.MCTCTFeatureExtractor | from typing import Optional, Union
from ....file_utils import PaddingStrategy, TensorType
from ....feature_extraction_utils import BatchFeature
from ....feature_extraction_sequence_utils import SequenceFeatureExtractor
from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function
import ... |
class MCTCTFeatureExtractor(SequenceFeatureExtractor):
'''
Constructs a M-CTC-T feature extractor.
This feature extractor inherits from [`~feature_extraction_sequence_utils.SequenceFeatureExtractor`] which contains
most of the main methods. Users should refer to this superclass for more information reg... | 6 | 3 | 43 | 5 | 28 | 10 | 4 | 0.55 | 1 | 10 | 1 | 0 | 5 | 16 | 5 | 22 | 256 | 33 | 144 | 64 | 110 | 79 | 71 | 36 | 65 | 13 | 3 | 2 | 22 |
1,791 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py | transformers.models.deprecated.mctct.modeling_mctct.MCTCTAttention | from torch import nn
from ....pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
class MCTCTAttention(nn.Module):
def __init__(self, config):
super().__init__()
self.self = MCTCTSelfAttention(config)
self.output = MCTCTSelfOutput(config)
... |
class MCTCTAttention(nn.Module):
def __init__(self, config):
pass
def prune_heads(self, heads):
pass
def forward(self, hidden_states, attention_mask=None, head_mask=None, output_attentions=False):
pass | 4 | 0 | 13 | 1 | 11 | 1 | 1 | 0.09 | 1 | 4 | 2 | 0 | 3 | 3 | 3 | 13 | 42 | 5 | 35 | 17 | 25 | 3 | 22 | 11 | 18 | 2 | 1 | 1 | 4 |
1,792 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py | transformers.models.deprecated.mctct.modeling_mctct.MCTCTConv1dSubsampler | from torch import nn
import torch
class MCTCTConv1dSubsampler(nn.Module):
"""
Convolutional subsampler: a stack of 1D convolution (along temporal dimension) followed by non-linear activation
via gated linear units (https://huggingface.co/papers/1911.08460)
"""
def __init__(self, config):
s... |
class MCTCTConv1dSubsampler(nn.Module):
'''
Convolutional subsampler: a stack of 1D convolution (along temporal dimension) followed by non-linear activation
via gated linear units (https://huggingface.co/papers/1911.08460)
'''
def __init__(self, config):
pass
def forward(self, input_f... | 3 | 1 | 26 | 4 | 20 | 5 | 4 | 0.33 | 1 | 3 | 0 | 0 | 2 | 10 | 2 | 12 | 59 | 10 | 40 | 16 | 37 | 13 | 27 | 16 | 24 | 5 | 1 | 2 | 7 |
1,793 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py | transformers.models.deprecated.mctct.modeling_mctct.MCTCTEmbeddings | from torch import nn
import torch
class MCTCTEmbeddings(nn.Module):
"""Construct the embeddings from word, position and token_type embeddings."""
def __init__(self, config):
super().__init__()
self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=config.pad_tok... |
class MCTCTEmbeddings(nn.Module):
'''Construct the embeddings from word, position and token_type embeddings.'''
def __init__(self, config):
pass
def forward(self, input_features=None, token_type_ids=None, position_ids=None, inputs_embeds=None, past_key_values_length=0):
pass | 3 | 1 | 26 | 5 | 18 | 4 | 4 | 0.22 | 1 | 2 | 1 | 0 | 2 | 5 | 2 | 12 | 56 | 11 | 37 | 16 | 32 | 8 | 28 | 14 | 25 | 6 | 1 | 2 | 7 |
1,794 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py | transformers.models.deprecated.mctct.modeling_mctct.MCTCTEncoder | from ....integrations.fsdp import is_fsdp_managed_module
from ....modeling_outputs import BaseModelOutput, CausalLMOutput
from ....modeling_attn_mask_utils import _prepare_4d_attention_mask
from typing import Optional, Union
import torch
from ....integrations.deepspeed import is_deepspeed_zero3_enabled
from torch impor... |
class MCTCTEncoder(MCTCTPreTrainedModel):
def __init__(self, config: MCTCTConfig):
pass
def forward(self, input_features: torch.Tensor, attention_mask: torch.Tensor, head_mask: torch.Tensor, output_attentions: bool=False, output_hidden_states: bool=False, return_dict: bool=True) -> Union[tuple, BaseM... | 3 | 0 | 46 | 9 | 35 | 3 | 11 | 0.09 | 1 | 12 | 5 | 0 | 2 | 5 | 2 | 134 | 94 | 18 | 70 | 25 | 59 | 6 | 44 | 17 | 41 | 20 | 3 | 3 | 21 |
1,795 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py | transformers.models.deprecated.mctct.modeling_mctct.MCTCTForCTC | from torch import nn
import torch
from ....file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ....modeling_outputs import BaseModelOutput, CausalLMOutput
from typing import Optional, Union
@add_start_docstrings('MCTCT Model with a `language modeling` head on ... | @add_start_docstrings('MCTCT Model with a `language modeling` head on top for Connectionist Temporal Classification (CTC).', MCTCT_START_DOCSTRING)
class MCTCTForCTC(MCTCTPreTrainedModel):
def __init__(self, config):
pass
@add_start_docstrings_to_model_forward(MCTCT_INPUTS_DOCSTRING)
@add_code_samp... | 6 | 1 | 44 | 6 | 32 | 6 | 5 | 0.16 | 1 | 6 | 2 | 0 | 2 | 2 | 2 | 134 | 98 | 13 | 73 | 26 | 53 | 12 | 30 | 16 | 27 | 7 | 3 | 2 | 9 |
1,796 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py | transformers.models.deprecated.mctct.modeling_mctct.MCTCTIntermediate | from torch import nn
from ....activations import ACT2FN
class MCTCTIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size, bias=False)
if isinstance(config.hidden_act, str):
self.intermediate_a... |
class MCTCTIntermediate(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 6 | 0 | 6 | 0 | 2 | 0 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 12 | 13 | 1 | 12 | 5 | 9 | 0 | 11 | 5 | 8 | 2 | 1 | 1 | 3 |
1,797 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py | transformers.models.deprecated.mctct.modeling_mctct.MCTCTLayer | from .configuration_mctct import MCTCTConfig
from ....modeling_layers import GradientCheckpointingLayer
from ....pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
class MCTCTLayer(GradientCheckpointingLayer):
def __init__(self, config: MCTCTConfig):
super... |
class MCTCTLayer(GradientCheckpointingLayer):
def __init__(self, config: MCTCTConfig):
pass
def forward(self, hidden_states, attention_mask=None, head_mask=None, output_attentions=False):
pass
def feed_forward_chunk(self, attention_output):
pass | 4 | 0 | 11 | 2 | 10 | 0 | 1 | 0.03 | 1 | 5 | 4 | 0 | 3 | 6 | 3 | 13 | 37 | 7 | 30 | 22 | 20 | 1 | 20 | 16 | 16 | 1 | 1 | 0 | 3 |
1,798 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py | transformers.models.deprecated.mctct.modeling_mctct.MCTCTLayerNorm | import torch
from torch import nn
class MCTCTLayerNorm(nn.Module):
def __init__(self):
super().__init__()
self.singleton_weight = nn.Parameter(torch.ones(1))
self.singleton_bias = nn.Parameter(torch.zeros(1))
def forward(self, hidden_states):
return hidden_states * self.single... |
class MCTCTLayerNorm(nn.Module):
def __init__(self):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 8 | 1 | 7 | 5 | 4 | 0 | 7 | 5 | 4 | 1 | 1 | 0 | 2 |
1,799 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/deprecated/mctct/modeling_mctct.py | transformers.models.deprecated.mctct.modeling_mctct.MCTCTModel | import torch
from typing import Optional, Union
from ....file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ....modeling_outputs import BaseModelOutput, CausalLMOutput
@add_start_docstrings('The bare M-CTC-T Model transformer outputting raw hidden-states with... | @add_start_docstrings('The bare M-CTC-T Model transformer outputting raw hidden-states without any specific head on top.', MCTCT_START_DOCSTRING)
class MCTCTModel(MCTCTPreTrainedModel):
def __init__(self, config):
pass
@add_start_docstrings_to_model_forward(MCTCT_INPUTS_DOCSTRING.format('batch_size, se... | 6 | 0 | 22 | 3 | 19 | 1 | 4 | 0.02 | 1 | 6 | 2 | 0 | 2 | 2 | 2 | 134 | 54 | 7 | 46 | 16 | 27 | 1 | 17 | 7 | 14 | 6 | 3 | 1 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.