id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | gold_code stringlengths 16 2.16M | v3_prompt_text stringlengths 90 96.1k | v3_target_text stringlengths 8 2.16M | imports stringlengths 0 54.7k | class_docstring stringclasses 1
value | num_functions int64 0 800 | num_cross_deps int64 0 755 | parallelizable_bodies int64 0 384 | docstring_coverage float64 0 1 | parse_ok bool 1
class | parse_error stringclasses 1
value | source stringclasses 1
value | body_spans_json stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/benchmark/benchmarks_entrypoint.py | benchmark.benchmarks_entrypoint.ImportModuleException | class ImportModuleException(Exception):
pass | """Implement class ImportModuleException.
Required methods (implement on the class; order is not specified):
"""
class ImportModuleException: | pass
| 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | |||
1 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/benchmark/benchmarks_entrypoint.py | benchmark.benchmarks_entrypoint.MetricsRecorder | import pandas as pd
import os
from datetime import datetime
import uuid
import logging
import json
class MetricsRecorder:
def __init__(self, connection, logger: logging.Logger, repository: str, branch: str, commit_id: str, commit_msg: str, collect_csv_data: bool=True):
self.conn = connection
self.... | """Implement class MetricsRecorder.
Required methods (implement on the class; order is not specified):
- `__init__(self, connection, logger: logging.Logger, repository: str, branch: str, commit_id: str, commit_msg: str, collect_csv_data: bool=True)`
- `initialise_benchmark(self, metadata: dict[str, str])`: Creates a n... |
def __init__(self, connection, logger: logging.Logger, repository: str, branch: str, commit_id: str, commit_msg: str, collect_csv_data: bool=True):
self.conn = connection
self.use_database = connection is not None
if self.use_database:
self.conn.autocommit = True
self.lo... | import pandas as pd
import os
from datetime import datetime
import uuid
import logging
import json | 8 | 2 | 6 | 0.625 | true | mrahman2025/OpenClassGen | [] | ||
2 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/configuration_my_new_model.py | configuration_my_new_model.MyNewModelConfig | from ...modeling_rope_utils import rope_config_validation
from ...configuration_utils import PretrainedConfig
class MyNewModelConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`MyNewModelModel`]. It is used to instantiate an MyNewModel
model according to the spe... | """This is the configuration class to store the configuration of a [`MyNewModelModel`]. It is used to instantiate an MyNewModel
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the MyNewModel-7B.
e.... | """
This is the configuration class to store the configuration of a [`MyNewModelModel`]. It is used to instantiate an MyNewModel
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the ... | from ...modeling_rope_utils import rope_config_validation
from ...configuration_utils import PretrainedConfig | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
3 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/configuration_my_new_model2.py | configuration_my_new_model2.MyNewModel2Config | from ...modeling_rope_utils import rope_config_validation
from ...configuration_utils import PretrainedConfig
class MyNewModel2Config(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`GemmaModel`]. It is used to instantiate an Gemma
model according to the specified ar... | """This is the configuration class to store the configuration of a [`GemmaModel`]. It is used to instantiate an Gemma
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the Gemma-7B.
e.g. [google/gemm... | """
This is the configuration class to store the configuration of a [`GemmaModel`]. It is used to instantiate an Gemma
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the Gemma-7B.
... | from ...modeling_rope_utils import rope_config_validation
from ...configuration_utils import PretrainedConfig | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
4 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/configuration_new_model.py | configuration_new_model.NewModelConfig | from ...configuration_utils import PretrainedConfig
class NewModelConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`NewModelModel`]. It is used to instantiate an NewModel
model according to the specified arguments, defining the model architecture. Instantiating... | """This is the configuration class to store the configuration of a [`NewModelModel`]. It is used to instantiate an NewModel
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the NewModel-7B.
e.g. [go... | """
This is the configuration class to store the configuration of a [`NewModelModel`]. It is used to instantiate an NewModel
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the NewM... | from ...configuration_utils import PretrainedConfig | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
5 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/conftest.py | conftest.CustomOutputChecker | class CustomOutputChecker(OutputChecker):
def check_output(self, want, got, optionflags):
if IGNORE_RESULT & optionflags:
return True
return OutputChecker.check_output(self, want, got, optionflags) | """Implement class CustomOutputChecker.
Required methods (implement on the class; order is not specified):
- `check_output(self, want, got, optionflags)`"""
class CustomOutputChecker: |
def check_output(self, want, got, optionflags):
if IGNORE_RESULT & optionflags:
return True
return OutputChecker.check_output(self, want, got, optionflags)
| 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | |||
6 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/.circleci/create_circleci_config.py | create_circleci_config.CircleCIJob | import copy
from typing import Any, Optional
from dataclasses import dataclass
import os
@dataclass
class CircleCIJob:
name: str
additional_env: dict[str, Any] = None
docker_image: list[dict[str, str]] = None
install_steps: list[str] = None
marker: Optional[str] = None
parallelism: Optional[int... | """Implement class CircleCIJob.
Required methods (implement on the class; order is not specified):
- `__post_init__(self)`
- `to_dict(self)`
- `job_name(self)`"""
import copy
from typing import Any, Optional
from dataclasses import dataclass
import os
class CircleCIJob: | class CircleCIJob:
name: str
additional_env: dict[str, Any] = None
docker_image: list[dict[str, str]] = None
install_steps: list[str] = None
marker: Optional[str] = None
parallelism: Optional[int] = 0
pytest_num_workers: int = 8
pytest_options: dict[str, Any] = None
resource_class: O... | import copy
from typing import Any, Optional
from dataclasses import dataclass
import os | 3 | 0 | 3 | 0 | true | mrahman2025/OpenClassGen | [] | ||
7 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/.circleci/create_circleci_config.py | create_circleci_config.EmptyJob | import copy
class EmptyJob:
job_name = 'empty'
def to_dict(self):
steps = [{'run': 'ls -la'}]
if self.job_name == 'collection_job':
steps.extend(['checkout', {'run': 'pip install requests || true'}, {'run': 'while [[ $(curl --location --request GET "https://circleci.com/api/v2/work... | """Implement class EmptyJob.
Required methods (implement on the class; order is not specified):
- `to_dict(self)`"""
import copy
class EmptyJob: | job_name = 'empty'
def to_dict(self):
steps = [{'run': 'ls -la'}]
if self.job_name == 'collection_job':
steps.extend(['checkout', {'run': 'pip install requests || true'}, {'run': 'while [[ $(curl --location --request GET "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job"... | import copy | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
8 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/image_processing_new_imgproc_model.py | image_processing_new_imgproc_model.ImgprocModelImageProcessor | from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
import torch
from ...image_transforms import convert_to_rgb, resize, to_channel_dimension_format
import numpy as np
from typing import Optional, Union
from ...utils import TensorType, filter_out_non_signature_kwargs, is_vision_availab... | """Constructs a IMGPROC_MODEL image processor.
Args:
do_resize (`bool`, *optional*, defaults to `True`):
Whether to resize the image's (height, width) dimensions to the specified `size`. Can be overridden by the
`do_resize` parameter in the `preprocess` method.
size (`dict`, *optional*, default... | """
Constructs a IMGPROC_MODEL image processor.
Args:
do_resize (`bool`, *optional*, defaults to `True`):
Whether to resize the image's (height, width) dimensions to the specified `size`. Can be overridden by the
`do_resize` parameter in the `preprocess` method.
size... | from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
import torch
from ...image_transforms import convert_to_rgb, resize, to_channel_dimension_format
import numpy as np
from typing import Optional, Union
from ...utils import TensorType, filter_out_non_signature_kwargs, is_vision_availab... | 4 | 1 | 3 | 0.5 | true | mrahman2025/OpenClassGen | [] | ||
9 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/pytorch-lightning/lightning_base.py | lightning_base.BaseTransformer | import os
from transformers.optimization import Adafactor, get_cosine_schedule_with_warmup, get_cosine_with_hard_restarts_schedule_with_warmup, get_linear_schedule_with_warmup, get_polynomial_decay_schedule_with_warmup
from typing import Any
import argparse
import pytorch_lightning as pl
from pathlib import Path
from t... | """Implement class BaseTransformer.
Required methods (implement on the class; order is not specified):
- `__init__(self, hparams: argparse.Namespace, num_labels=None, mode='base', config=None, tokenizer=None, model=None, **config_kwargs)`: Initialize a model, tokenizer and config.
- `load_hf_checkpoint(self, *args, **... |
def __init__(self, hparams: argparse.Namespace, num_labels=None, mode='base', config=None, tokenizer=None, model=None, **config_kwargs):
"""Initialize a model, tokenizer and config."""
super().__init__()
self.save_hyperparameters(hparams)
self.step_count = 0
self.output_dir ... | import os
from transformers.optimization import Adafactor, get_cosine_schedule_with_warmup, get_cosine_with_hard_restarts_schedule_with_warmup, get_linear_schedule_with_warmup, get_polynomial_decay_schedule_with_warmup
from typing import Any
import argparse
import pytorch_lightning as pl
from pathlib import Path
from t... | 15 | 7 | 7 | 0.2 | true | mrahman2025/OpenClassGen | [] | ||
10 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/pytorch-lightning/lightning_base.py | lightning_base.LoggingCallback | import pytorch_lightning as pl
import os
from pytorch_lightning.utilities import rank_zero_info
class LoggingCallback(pl.Callback):
def on_batch_end(self, trainer, pl_module):
lr_scheduler = trainer.lr_schedulers[0]['scheduler']
lrs = {f'lr_group_{i}': lr for i, lr in enumerate(lr_scheduler.get_lr... | """Implement class LoggingCallback.
Required methods (implement on the class; order is not specified):
- `on_batch_end(self, trainer, pl_module)`
- `on_validation_end(self, trainer: pl.Trainer, pl_module: pl.LightningModule)`
- `on_test_end(self, trainer: pl.Trainer, pl_module: pl.LightningModule)`"""
import pytorch_l... |
def on_batch_end(self, trainer, pl_module):
lr_scheduler = trainer.lr_schedulers[0]['scheduler']
lrs = {f'lr_group_{i}': lr for i, lr in enumerate(lr_scheduler.get_lr())}
pl_module.logger.log_metrics(lrs)
def on_validation_end(self, trainer: pl.Trainer, pl_module: pl.LightningModule):
... | import pytorch_lightning as pl
import os
from pytorch_lightning.utilities import rank_zero_info | 3 | 0 | 3 | 0 | true | mrahman2025/OpenClassGen | [] | ||
11 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_add_function.py | modeling_add_function.TestAttention | from ...utils.deprecation import deprecate_kwarg
import torch
from torch import nn
from typing import Optional
class TestAttention(nn.Module):
"""
Multi-headed attention from 'Attention Is All You Need' paper. Modified to use sliding window attention: Longformer
and "Generating Long Sequences with Sparse T... | """Multi-headed attention from 'Attention Is All You Need' paper. Modified to use sliding window attention: Longformer
and "Generating Long Sequences with Sparse Transformers".
Adapted from transformers.models.mistral.modeling_mistral.MistralAttention:
The input dimension here is attention_hidden_size = 2 * hidden_siz... | """
Multi-headed attention from 'Attention Is All You Need' paper. Modified to use sliding window attention: Longformer
and "Generating Long Sequences with Sparse Transformers".
Adapted from transformers.models.mistral.modeling_mistral.MistralAttention:
The input dimension here is attention_hidden_... | from ...utils.deprecation import deprecate_kwarg
import torch
from torch import nn
from typing import Optional | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
12 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertAttention | import torch
from torch import nn
from typing import Optional, Union
from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
class DummyBertAttention... | """Implement class DummyBertAttention.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, position_embedding_type=None, layer_idx=None)`
- `prune_heads(self, heads)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Opti... |
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super().__init__()
self.self = DUMMY_BERT_SELF_ATTENTION_CLASSES[config._attn_implementation](config, position_embedding_type=position_embedding_type, layer_idx=layer_idx)
self.output = DummyBertSelfOutput(config)
... | import torch
from torch import nn
from typing import Optional, Union
from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer | 3 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
13 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertEmbeddings | import torch
from torch import nn
from typing import Optional, Union
class DummyBertEmbeddings(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.... | """Construct the embeddings from word, position and token_type embeddings.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, input_ids: Optional[torch.LongTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, position_ids: Optional[torch.LongTensor]... | """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_token_id)
self.position_embeddings = nn.Embedding(config.max_pos... | import torch
from torch import nn
from typing import Optional, Union | 2 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
14 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertEncoder | from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from torch import nn
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions
import torch
class DummyBertEncoder(nn.Module):
def __init__(self, con... | """Implement class DummyBertEncoder.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, layer_idx=None)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, encoder_hidden_states: Optional... |
def __init__(self, config, layer_idx=None):
super().__init__()
self.config = config
self.layer = nn.ModuleList([DummyBertLayer(config, layer_idx=i) for i in range(config.num_hidden_layers)])
self.gradient_checkpointing = False
def forward(self, hidden_states: torch.Tensor, atte... | from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from torch import nn
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions
import torch | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
15 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertIntermediate | import torch
from torch import nn
from ...activations import ACT2FN
class DummyBertIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act, str):
self.intermedia... | """Implement class DummyBertIntermediate.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, hidden_states: torch.Tensor)`"""
import torch
from torch import nn
from ...activations import ACT2FN
class DummyBertIntermediate: |
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act, str):
self.intermediate_act_fn = ACT2FN[config.hidden_act]
else:
self.intermediate_act_fn = config.hidden_act
... | import torch
from torch import nn
from ...activations import ACT2FN | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
16 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertLayer | from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
import torch
from ...modeling_layers import GradientCheckpointingLayer
from typing import Optional, Union
from ...utils.deprecation import depr... | """Implement class DummyBertLayer.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, layer_idx=None)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, encoder_hidden_states: Optional[t... |
def __init__(self, config, layer_idx=None):
super().__init__()
self.chunk_size_feed_forward = config.chunk_size_feed_forward
self.seq_len_dim = 1
self.attention = DummyBertAttention(config, layer_idx=layer_idx)
self.is_decoder = config.is_decoder
self.add_cross_atten... | from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
import torch
from ...modeling_layers import GradientCheckpointingLayer
from typing import Optional, Union
from ...utils.deprecation import depr... | 3 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
17 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertModel | from ...utils import auto_docstring, logging
import torch
from typing import Optional, Union
from ...modeling_attn_mask_utils import _prepare_4d_attention_mask_for_sdpa, _prepare_4d_causal_attention_mask_for_sdpa
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCro... | """Implement class DummyBertModel.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, add_pooling_layer=True)`: add_pooling_layer (bool, *optional*, defaults to `True`):
- `get_input_embeddings(self)`
- `set_input_embeddings(self, value)`
- `_prune_heads(self, heads_to_prune)`... | class DummyBertModel(DummyBertPreTrainedModel):
_no_split_modules = ['DummyBertEmbeddings', 'DummyBertLayer']
def __init__(self, config, add_pooling_layer=True):
"""
add_pooling_layer (bool, *optional*, defaults to `True`):
Whether to add a pooling layer
"""
super().... | from ...utils import auto_docstring, logging
import torch
from typing import Optional, Union
from ...modeling_attn_mask_utils import _prepare_4d_attention_mask_for_sdpa, _prepare_4d_causal_attention_mask_for_sdpa
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCro... | 5 | 0 | 3 | 0.4 | true | mrahman2025/OpenClassGen | [] | ||
18 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertOutput | import torch
from torch import nn
class DummyBertOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.intermediate_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.dropout = nn.Dro... | """Implement class DummyBertOutput.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor)`"""
import torch
from torch import nn
class DummyBertOutput: |
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.intermediate_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
def forward(self, hidden_states... | import torch
from torch import nn | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
19 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertPooler | from torch import nn
import torch
class DummyBertPooler(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.activation = nn.Tanh()
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
first_t... | """Implement class DummyBertPooler.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, hidden_states: torch.Tensor)`"""
from torch import nn
import torch
class DummyBertPooler: |
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.activation = nn.Tanh()
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
first_token_tensor = hidden_states[:, 0]
pooled_output = self.dense(... | from torch import nn
import torch | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
20 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertPreTrainedModel | from ...modeling_utils import PreTrainedModel
from .configuration_dummy_bert import DummyBertConfig
from ...utils import auto_docstring, logging
from torch import nn
@auto_docstring
class DummyBertPreTrainedModel(PreTrainedModel):
config: DummyBertConfig
base_model_prefix = 'dummy_bert'
supports_gradient_c... | """Implement class DummyBertPreTrainedModel.
Required methods (implement on the class; order is not specified):
- `_init_weights(self, module)`: Initialize the weights"""
from ...modeling_utils import PreTrainedModel
from .configuration_dummy_bert import DummyBertConfig
from ...utils import auto_docstring, logging
fro... | class DummyBertPreTrainedModel(PreTrainedModel):
config: DummyBertConfig
base_model_prefix = 'dummy_bert'
supports_gradient_checkpointing = True
_supports_sdpa = True
def _init_weights(self, module):
"""Initialize the weights"""
if isinstance(module, nn.Linear):
module.w... | from ...modeling_utils import PreTrainedModel
from .configuration_dummy_bert import DummyBertConfig
from ...utils import auto_docstring, logging
from torch import nn | 1 | 0 | 1 | 1 | true | mrahman2025/OpenClassGen | [] | ||
21 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertSdpaSelfAttention | from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
import torch
class DummyBertSdpaSelfAttention(DummyBertSelfAttention):
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super()._... | """Implement class DummyBertSdpaSelfAttention.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, position_embedding_type=None, layer_idx=None)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, head_mask: Optional[torch.FloatTensor]=No... |
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super().__init__(config, position_embedding_type=position_embedding_type, layer_idx=layer_idx)
self.dropout_prob = config.attention_probs_dropout_prob
@deprecate_kwarg('past_key_value', new_name='past_key_values', versio... | from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
import torch | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
22 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertSelfAttention | import math
import torch
from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from torch import nn
from typing import Optional, Union
class DummyBertSelfAttention(nn.Module):
def __init__(self, config, position_embedding_type=None, layer_idx=None):
... | """Implement class DummyBertSelfAttention.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, position_embedding_type=None, layer_idx=None)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=N... |
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super().__init__()
if config.hidden_size % config.num_attention_heads != 0 and (not hasattr(config, 'embedding_size')):
raise ValueError(f'The hidden size ({config.hidden_size}) is not a multiple of the number of ... | import math
import torch
from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from torch import nn
from typing import Optional, Union | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
23 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_dummy_bert.py | modeling_dummy_bert.DummyBertSelfOutput | import torch
from torch import nn
class DummyBertSelfOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.dropout = nn.Dropo... | """Implement class DummyBertSelfOutput.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor)`"""
import torch
from torch import nn
class DummyBertSelfOutput: |
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
def forward(self, hidden_states: torc... | import torch
from torch import nn | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
24 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_from_uppercase_model.py | modeling_from_uppercase_model.FromUppercaseModelAttention | import torch
from .configuration_from_uppercase_model import FromUppercaseModelTextConfig, FromUppercaseModelVisionConfig
from torch import nn
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS
from typing import Callable, Optional, Union
class FromUppercaseModelAttention(nn.Module):
"""Multi-headed attention f... | """Multi-headed attention from 'Attention Is All You Need' paper
Required methods (implement on the class; order is not specified):
- `__init__(self, config: Union[FromUppercaseModelVisionConfig, FromUppercaseModelTextConfig])`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, ... | """Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config: Union[FromUppercaseModelVisionConfig, FromUppercaseModelTextConfig]):
super().__init__()
self.config = config
self.embed_dim = config.hidden_size
self.num_heads = config.num_attention_... | import torch
from .configuration_from_uppercase_model import FromUppercaseModelTextConfig, FromUppercaseModelVisionConfig
from torch import nn
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS
from typing import Callable, Optional, Union | 2 | 0 | 1 | 0.5 | true | mrahman2025/OpenClassGen | [] | ||
25 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_from_uppercase_model.py | modeling_from_uppercase_model.FromUppercaseModelEncoderLayer | from ...modeling_layers import GradientCheckpointingLayer
from .configuration_from_uppercase_model import FromUppercaseModelTextConfig, FromUppercaseModelVisionConfig
from torch import nn
from typing import Callable, Optional, Union
import torch
class FromUppercaseModelEncoderLayer(GradientCheckpointingLayer):
de... | """Implement class FromUppercaseModelEncoderLayer.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: Union[FromUppercaseModelVisionConfig, FromUppercaseModelTextConfig])`
- `forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, causal_attention_mask: torch.... |
def __init__(self, config: Union[FromUppercaseModelVisionConfig, FromUppercaseModelTextConfig]):
super().__init__()
self.embed_dim = config.hidden_size
self.self_attn = FromUppercaseModelAttention(config)
self.layer_norm1 = nn.LayerNorm(self.embed_dim, eps=config.layer_norm_eps)
... | from ...modeling_layers import GradientCheckpointingLayer
from .configuration_from_uppercase_model import FromUppercaseModelTextConfig, FromUppercaseModelVisionConfig
from torch import nn
from typing import Callable, Optional, Union
import torch | 2 | 0 | 1 | 0.5 | true | mrahman2025/OpenClassGen | [] | ||
26 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_from_uppercase_model.py | modeling_from_uppercase_model.FromUppercaseModelMLP | import torch
from torch import nn
from ...activations import ACT2FN
class FromUppercaseModelMLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.activation_fn = ACT2FN[config.hidden_act]
self.fc1 = nn.Linear(config.hidden_size, config.intermediat... | """Implement class FromUppercaseModelMLP.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, hidden_states: torch.Tensor)`"""
import torch
from torch import nn
from ...activations import ACT2FN
class FromUppercaseModelMLP: |
def __init__(self, config):
super().__init__()
self.config = config
self.activation_fn = ACT2FN[config.hidden_act]
self.fc1 = nn.Linear(config.hidden_size, config.intermediate_size)
self.fc2 = nn.Linear(config.intermediate_size, config.hidden_size)
def forward(self, hid... | import torch
from torch import nn
from ...activations import ACT2FN | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
27 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_multimodal2.py | modeling_multimodal2.Multimodal2VisionAttention | from torch import nn
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
import torch
from typing import Callable, Optional, Union
from .configuration_multimodal2 import Multimodal2Config, Multimodal2TextConfig, Multimodal2VisionConfig
class Multimodal2VisionAttention(nn.Module):
"""Multi-headed... | """Multi-headed attention from 'Attention Is All You Need' paper
Required methods (implement on the class; order is not specified):
- `__init__(self, config: Union[Multimodal2VisionConfig, Multimodal2TextConfig])`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, causal_attenti... | """Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config: Union[Multimodal2VisionConfig, Multimodal2TextConfig]):
super().__init__()
self.config = config
self.embed_dim = config.hidden_size
self.num_heads = config.num_attention_heads
... | from torch import nn
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
import torch
from typing import Callable, Optional, Union
from .configuration_multimodal2 import Multimodal2Config, Multimodal2TextConfig, Multimodal2VisionConfig | 2 | 0 | 1 | 0.5 | true | mrahman2025/OpenClassGen | [] | ||
28 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_multimodal2.py | modeling_multimodal2.Multimodal2VisionEmbeddings | from torch import nn
import torch
from .configuration_multimodal2 import Multimodal2Config, Multimodal2TextConfig, Multimodal2VisionConfig
from ...utils import auto_docstring, can_return_tuple, torch_int
class Multimodal2VisionEmbeddings(nn.Module):
def __init__(self, config: Multimodal2VisionConfig):
sup... | """Implement class Multimodal2VisionEmbeddings.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: Multimodal2VisionConfig)`
- `interpolate_pos_encoding(self, embeddings: torch.Tensor, height: int, width: int)`: This method allows to interpolate the pre-trained position encodi... |
def __init__(self, config: Multimodal2VisionConfig):
super().__init__()
self.config = config
self.embed_dim = config.hidden_size
self.image_size = config.image_size
self.patch_size = config.patch_size
self.class_embedding = nn.Parameter(torch.randn(self.embed_dim))
... | from torch import nn
import torch
from .configuration_multimodal2 import Multimodal2Config, Multimodal2TextConfig, Multimodal2VisionConfig
from ...utils import auto_docstring, can_return_tuple, torch_int | 3 | 1 | 0 | 0.333333 | true | mrahman2025/OpenClassGen | [] | ||
29 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_multimodal2.py | modeling_multimodal2.Multimodal2VisionEncoder | from typing import Callable, Optional, Union
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
from torch import nn
import torch
class Multimodal2VisionEncoder(nn.Module):
"""
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`Mul... | """Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`Multimodal2VisionEncoderLayer`].
Args:
config: Multimodal2VisionConfig
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, inputs_embeds, attention_ma... | """
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`Multimodal2VisionEncoderLayer`].
Args:
config: Multimodal2VisionConfig
"""
def __init__(self, config):
super().__init__()
self.config = config
self.layers =... | from typing import Callable, Optional, Union
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
from torch import nn
import torch | 2 | 0 | 2 | 0.5 | true | mrahman2025/OpenClassGen | [] | ||
30 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_multimodal2.py | modeling_multimodal2.Multimodal2VisionEncoderLayer | import torch
from ...modeling_layers import GradientCheckpointingLayer
from typing import Callable, Optional, Union
from torch import nn
class Multimodal2VisionEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config):
super().__init__()
self.embed_dim = config.hidden_size
self.... | """Implement class Multimodal2VisionEncoderLayer.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, causal_attention_mask: torch.Tensor, output_attentions: Optional[bool]=False)`: Args:"""
import tor... |
def __init__(self, config):
super().__init__()
self.embed_dim = config.hidden_size
self.self_attn = Multimodal2Attention(config)
self.layer_norm1 = nn.LayerNorm(self.embed_dim, eps=config.layer_norm_eps)
self.mlp = Multimodal2VisionMLP(config)
self.layer_norm2 = nn.L... | import torch
from ...modeling_layers import GradientCheckpointingLayer
from typing import Callable, Optional, Union
from torch import nn | 2 | 0 | 1 | 0.5 | true | mrahman2025/OpenClassGen | [] | ||
31 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_multimodal2.py | modeling_multimodal2.Multimodal2VisionMLP | from torch import nn
from ...activations import ACT2FN
import torch
class Multimodal2VisionMLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.activation_fn = ACT2FN[config.hidden_act]
self.fc1 = nn.Linear(config.hidden_size, config.intermediate... | """Implement class Multimodal2VisionMLP.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, hidden_states: torch.Tensor)`"""
from torch import nn
from ...activations import ACT2FN
import torch
class Multimodal2VisionMLP: |
def __init__(self, config):
super().__init__()
self.config = config
self.activation_fn = ACT2FN[config.hidden_act]
self.fc1 = nn.Linear(config.hidden_size, config.intermediate_size)
self.fc2 = nn.Linear(config.intermediate_size, config.hidden_size)
def forward(self, hid... | from torch import nn
from ...activations import ACT2FN
import torch | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
32 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_multimodal2.py | modeling_multimodal2.Multimodal2VisionModel | from typing import Callable, Optional, Union
from torch import nn
import torch
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
from .configuration_multimodal2 import Multimodal2Config, Multimodal2TextConfig, Multimodal2VisionConfig
from ...utils import auto_docstring, can_return_tuple, torch... | """Implement class Multimodal2VisionModel.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: Multimodal2VisionConfig)`
- `get_input_embeddings(self)`
- `forward(self, pixel_values: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=None, output_hidden_states:... | class Multimodal2VisionModel(Multimodal2VisionPreTrainedModel):
config: Multimodal2VisionConfig
main_input_name = 'pixel_values'
_no_split_modules = ['Multimodal2VisionEncoderLayer']
def __init__(self, config: Multimodal2VisionConfig):
super().__init__(config)
self.vision_model = Multim... | from typing import Callable, Optional, Union
from torch import nn
import torch
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
from .configuration_multimodal2 import Multimodal2Config, Multimodal2TextConfig, Multimodal2VisionConfig
from ...utils import auto_docstring, can_return_tuple, torch... | 3 | 0 | 1 | 0.333333 | true | mrahman2025/OpenClassGen | [] | ||
33 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_multimodal2.py | modeling_multimodal2.Multimodal2VisionPreTrainedModel | from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_multimodal2 import Multimodal2Config, Multimodal2TextConfig, Multimodal2VisionConfig
from ...utils import auto_docstring, can_return_tuple, torch_int
@auto_docstring
class Multimodal2VisionPreTrainedModel(PreTrainedModel):
c... | """Implement class Multimodal2VisionPreTrainedModel.
Required methods (implement on the class; order is not specified):
- `_init_weights(self, module)`: Initialize the weights"""
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_multimodal2 import Multimodal2Config, Multimodal2... | class Multimodal2VisionPreTrainedModel(PreTrainedModel):
config: Multimodal2Config
base_model_prefix = 'multimodal2_vision'
supports_gradient_checkpointing = True
_supports_sdpa = True
_supports_flash_attn = True
_supports_flex_attn = True
_supports_attention_backend = True
def _init_we... | from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_multimodal2 import Multimodal2Config, Multimodal2TextConfig, Multimodal2VisionConfig
from ...utils import auto_docstring, can_return_tuple, torch_int | 1 | 0 | 1 | 1 | true | mrahman2025/OpenClassGen | [] | ||
34 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_multimodal2.py | modeling_multimodal2.Multimodal2VisionTransformer | import torch
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
from typing import Callable, Optional, Union
from ...utils import auto_docstring, can_return_tuple, torch_int
from torch import nn
class Multimodal2VisionTransformer(nn.Module):
def __init__(self, config):
super().__i... | """Implement class Multimodal2VisionTransformer.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, pixel_values: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=None, output_hidden_states: Optional[bool]=None, interpolate_pos_encoding: Op... |
def __init__(self, config):
super().__init__()
self.config = config
embed_dim = config.hidden_size
self.embeddings = Multimodal2VisionEmbeddings(config)
self.pre_layrnorm = nn.LayerNorm(embed_dim, eps=config.layer_norm_eps)
self.encoder = Multimodal2VisionEncoder(con... | import torch
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
from typing import Callable, Optional, Union
from ...utils import auto_docstring, can_return_tuple, torch_int
from torch import nn | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
35 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_my_new_model2.py | modeling_my_new_model2.MyNewModel2Attention | from .configuration_my_new_model2 import MyNewModel2Config
from ...processing_utils import Unpack
from typing import Callable, Optional
from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from torch import nn
from ...ut... | """Multi-headed attention from 'Attention Is All You Need' paper
Required methods (implement on the class; order is not specified):
- `__init__(self, config: MyNewModel2Config, layer_idx: int)`
- `forward(self, hidden_states: torch.Tensor, position_embeddings: tuple[torch.Tensor, torch.Tensor], attention_mask: Optiona... | """Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config: MyNewModel2Config, layer_idx: int):
super().__init__()
self.config = config
self.layer_idx = layer_idx
self.head_dim = getattr(config, 'head_dim', config.hidden_size // config.num_atte... | from .configuration_my_new_model2 import MyNewModel2Config
from ...processing_utils import Unpack
from typing import Callable, Optional
from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from torch import nn
from ...ut... | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
36 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_my_new_model2.py | modeling_my_new_model2.MyNewModel2DecoderLayer | from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer
from ...cache_utils import Cache
from .configuration_my_new_model2 import MyNewModel2Config
from ...utils.deprecation import deprecate_kwarg
from ...utils import TransformersKwargs, auto_docstring
import torch
from typing import... | """Implement class MyNewModel2DecoderLayer.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: MyNewModel2Config, layer_idx: int)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, position_ids: Optional[torch.LongTensor]=None, past_key... |
def __init__(self, config: MyNewModel2Config, layer_idx: int):
super().__init__()
self.hidden_size = config.hidden_size
self.self_attn = MyNewModel2Attention(config=config, layer_idx=layer_idx)
self.mlp = MyNewModel2MLP(config)
self.input_layernorm = MyNewModel2RMSNorm(confi... | from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer
from ...cache_utils import Cache
from .configuration_my_new_model2 import MyNewModel2Config
from ...utils.deprecation import deprecate_kwarg
from ...utils import TransformersKwargs, auto_docstring
import torch
from typing import... | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
37 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_my_new_model2.py | modeling_my_new_model2.MyNewModel2ForSequenceClassification | from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer
class MyNewModel2ForSequenceClassification(GenericForSequenceClassification, MyNewModel2PreTrainedModel):
pass | """Implement class MyNewModel2ForSequenceClassification.
Required methods (implement on the class; order is not specified):
"""
from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer
class MyNewModel2ForSequenceClassification: | pass
| from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
38 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_my_new_model2.py | modeling_my_new_model2.MyNewModel2MLP | from torch import nn
from ...activations import ACT2FN
class MyNewModel2MLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.hidden_size = config.hidden_size
self.intermediate_size = config.intermediate_size
self.gate_proj = nn.Linear(sel... | """Implement class MyNewModel2MLP.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, x)`"""
from torch import nn
from ...activations import ACT2FN
class MyNewModel2MLP: |
def __init__(self, config):
super().__init__()
self.config = config
self.hidden_size = config.hidden_size
self.intermediate_size = config.intermediate_size
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
self.up_proj = nn.Linear(self.... | from torch import nn
from ...activations import ACT2FN | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
39 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_my_new_model2.py | modeling_my_new_model2.MyNewModel2PreTrainedModel | from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_my_new_model2 import MyNewModel2Config
from ...utils import TransformersKwargs, auto_docstring
@auto_docstring
class MyNewModel2PreTrainedModel(PreTrainedModel):
config: MyNewModel2Config
base_model_prefix = 'model'
... | """Implement class MyNewModel2PreTrainedModel.
Required methods (implement on the class; order is not specified):
"""
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_my_new_model2 import MyNewModel2Config
from ...utils import TransformersKwargs, auto_docstring
class MyNewMod... | class MyNewModel2PreTrainedModel(PreTrainedModel):
config: MyNewModel2Config
base_model_prefix = 'model'
supports_gradient_checkpointing = True
_no_split_modules = ['MyNewModel2DecoderLayer']
_skip_keys_device_placement = ['past_key_values']
_supports_flash_attn = True
_supports_sdpa = True
... | from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_my_new_model2 import MyNewModel2Config
from ...utils import TransformersKwargs, auto_docstring | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
40 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_my_new_model2.py | modeling_my_new_model2.MyNewModel2RMSNorm | import torch
from torch import nn
class MyNewModel2RMSNorm(nn.Module):
def __init__(self, dim: int, eps: float=1e-06):
super().__init__()
self.eps = eps
self.weight = nn.Parameter(torch.zeros(dim))
def _norm(self, x):
return x * torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + se... | """Implement class MyNewModel2RMSNorm.
Required methods (implement on the class; order is not specified):
- `__init__(self, dim: int, eps: float=1e-06)`
- `_norm(self, x)`
- `forward(self, x)`
- `extra_repr(self)`"""
import torch
from torch import nn
class MyNewModel2RMSNorm: |
def __init__(self, dim: int, eps: float=1e-06):
super().__init__()
self.eps = eps
self.weight = nn.Parameter(torch.zeros(dim))
def _norm(self, x):
return x * torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + self.eps)
def forward(self, x):
output = self._norm(x.float()... | import torch
from torch import nn | 4 | 1 | 3 | 0 | true | mrahman2025/OpenClassGen | [] | ||
41 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_new_task_model.py | modeling_new_task_model.NewTaskModelCausalLMOutputWithPast | import torch
from dataclasses import dataclass
from ...cache_utils import Cache, StaticCache
from typing import ClassVar, Optional, Union
from ...utils import ModelOutput, auto_docstring, can_return_tuple
@dataclass
@auto_docstring(custom_intro='\n Base class for NewTaskModel causal language model (or autoregressiv... | """loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Language modeling loss (for next-token prediction).
logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.text_config.vocab_size)`):
Prediction scores of the language modeling head (scores for eac... | @auto_docstring(custom_intro='\n Base class for NewTaskModel causal language model (or autoregressive) outputs.\n ')
class NewTaskModelCausalLMOutputWithPast(ModelOutput):
"""
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Language modeling loss (for ne... | import torch
from dataclasses import dataclass
from ...cache_utils import Cache, StaticCache
from typing import ClassVar, Optional, Union
from ...utils import ModelOutput, auto_docstring, can_return_tuple | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
42 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_new_task_model.py | modeling_new_task_model.NewTaskModelForNewTask | from ...utils import ModelOutput, auto_docstring, can_return_tuple
from ...cache_utils import Cache, StaticCache
from ...generation import GenerationMixin
from torch import nn
from typing import ClassVar, Optional, Union
import torch
@auto_docstring(custom_intro='\n The Base NewTaskModel model which consists of a v... | """Implement class NewTaskModelForNewTask.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `get_input_embeddings(self)`
- `set_input_embeddings(self, value)`
- `set_decoder(self, decoder)`
- `get_decoder(self)`
- `get_image_features(self, pixel_values)`
- `language_model... | class NewTaskModelForNewTask(NewTaskModelPreTrainedModel, GenerationMixin):
_checkpoint_conversion_mapping = {'^language_model.model': 'model.language_model', '^vision_tower': 'model.vision_tower', '^multi_modal_projector': 'model.multi_modal_projector', '^language_model.lm_head': 'lm_head'}
_tied_weights_keys ... | from ...utils import ModelOutput, auto_docstring, can_return_tuple
from ...cache_utils import Cache, StaticCache
from ...generation import GenerationMixin
from torch import nn
from typing import ClassVar, Optional, Union
import torch | 13 | 0 | 11 | 0.153846 | true | mrahman2025/OpenClassGen | [] | ||
43 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_new_task_model.py | modeling_new_task_model.NewTaskModelMultiModalProjector | from .configuration_new_task_model import NewTaskModelConfig
from torch import nn
class NewTaskModelMultiModalProjector(nn.Module):
def __init__(self, config: NewTaskModelConfig):
super().__init__()
self.linear = nn.Linear(config.vision_config.hidden_size, config.vision_config.projection_dim, bias... | """Implement class NewTaskModelMultiModalProjector.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: NewTaskModelConfig)`
- `forward(self, image_features)`"""
from .configuration_new_task_model import NewTaskModelConfig
from torch import nn
class NewTaskModelMultiModalProje... |
def __init__(self, config: NewTaskModelConfig):
super().__init__()
self.linear = nn.Linear(config.vision_config.hidden_size, config.vision_config.projection_dim, bias=True)
def forward(self, image_features):
hidden_states = self.linear(image_features)
return hidden_states
| from .configuration_new_task_model import NewTaskModelConfig
from torch import nn | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
44 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_new_task_model.py | modeling_new_task_model.NewTaskModelPreTrainedModel | from .configuration_new_task_model import NewTaskModelConfig
from ...utils import ModelOutput, auto_docstring, can_return_tuple
from torch import nn
from ...modeling_utils import PreTrainedModel
@auto_docstring
class NewTaskModelPreTrainedModel(PreTrainedModel):
config: NewTaskModelConfig
base_model_prefix = '... | """Implement class NewTaskModelPreTrainedModel.
Required methods (implement on the class; order is not specified):
- `_init_weights(self, module)`"""
from .configuration_new_task_model import NewTaskModelConfig
from ...utils import ModelOutput, auto_docstring, can_return_tuple
from torch import nn
from ...modeling_uti... | class NewTaskModelPreTrainedModel(PreTrainedModel):
config: NewTaskModelConfig
base_model_prefix = ''
supports_gradient_checkpointing = True
_no_split_modules = ['NewTaskModelMultiModalProjector']
_skip_keys_device_placement = 'past_key_values'
_can_compile_fullgraph = False
_supports_flash_... | from .configuration_new_task_model import NewTaskModelConfig
from ...utils import ModelOutput, auto_docstring, can_return_tuple
from torch import nn
from ...modeling_utils import PreTrainedModel | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
45 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_roberta.py | modeling_roberta.RobertaAttention | import torch.nn as nn
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
import torch
from typing import Optional, Union
from ...utils.deprecation import deprecate_kwarg
class RobertaAttention(... | """Implement class RobertaAttention.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, position_embedding_type=None, layer_idx=None)`
- `prune_heads(self, heads)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Option... |
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super().__init__()
self.self = ROBERTA_SELF_ATTENTION_CLASSES[config._attn_implementation](config, position_embedding_type=position_embedding_type, layer_idx=layer_idx)
self.output = RobertaSelfOutput(config)
... | import torch.nn as nn
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
import torch
from typing import Optional, Union
from ...utils.deprecation import deprecate_kwarg | 3 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
46 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_roberta.py | modeling_roberta.RobertaEmbeddings | import torch.nn as nn
from typing import Optional, Union
import torch
class RobertaEmbeddings(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.h... | """Construct the embeddings from word, position and token_type embeddings.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, input_ids: Optional[torch.LongTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, position_ids: Optional[torch.LongTensor]... | """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_token_id)
self.position_embeddings = nn.Embedding(config.max_pos... | import torch.nn as nn
from typing import Optional, Union
import torch | 2 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
47 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_roberta.py | modeling_roberta.RobertaEncoder | from typing import Optional, Union
import torch.nn as nn
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions
import torch
class RobertaEncoder(nn.Module):
def __init__(self, conf... | """Implement class RobertaEncoder.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, layer_idx=None)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, encoder_hidden_states: Optional[t... |
def __init__(self, config, layer_idx=None):
super().__init__()
self.config = config
self.layer = nn.ModuleList([RobertaLayer(config, layer_idx=i) for i in range(config.num_hidden_layers)])
self.gradient_checkpointing = False
def forward(self, hidden_states: torch.Tensor, attent... | from typing import Optional, Union
import torch.nn as nn
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions
import torch | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
48 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_roberta.py | modeling_roberta.RobertaIntermediate | from ...activations import ACT2FN
import torch.nn as nn
import torch
class RobertaIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act, str):
self.intermediat... | """Implement class RobertaIntermediate.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, hidden_states: torch.Tensor)`"""
from ...activations import ACT2FN
import torch.nn as nn
import torch
class RobertaIntermediate: |
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act, str):
self.intermediate_act_fn = ACT2FN[config.hidden_act]
else:
self.intermediate_act_fn = config.hidden_act
... | from ...activations import ACT2FN
import torch.nn as nn
import torch | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
49 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_roberta.py | modeling_roberta.RobertaLayer | from typing import Optional, Union
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
from ...utils.deprecation import deprecate_kwarg
from ...modeling_layers import GradientCheckpointingLayer
import torch.nn as nn
from ...cache_utils import Cache, DynamicCache,... | """Implement class RobertaLayer.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, layer_idx=None)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, encoder_hidden_states: Optional[tor... |
def __init__(self, config, layer_idx=None):
super().__init__()
self.chunk_size_feed_forward = config.chunk_size_feed_forward
self.seq_len_dim = 1
self.attention = RobertaAttention(config, layer_idx=layer_idx)
self.is_decoder = config.is_decoder
self.add_cross_attenti... | from typing import Optional, Union
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
from ...utils.deprecation import deprecate_kwarg
from ...modeling_layers import GradientCheckpointingLayer
import torch.nn as nn
from ...cache_utils import Cache, DynamicCache,... | 3 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
50 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_roberta.py | modeling_roberta.RobertaModel | import torch
import torch.nn as nn
from ...modeling_attn_mask_utils import _prepare_4d_attention_mask_for_sdpa, _prepare_4d_causal_attention_mask_for_sdpa
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithPastAndCros... | """Implement class RobertaModel.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, add_pooling_layer=True)`: add_pooling_layer (bool, *optional*, defaults to `True`):
- `get_input_embeddings(self)`
- `set_input_embeddings(self, value)`
- `_prune_heads(self, heads_to_prune)`: ... | class RobertaModel(RobertaPreTrainedModel):
_no_split_modules = ['RobertaEmbeddings', 'RobertaLayer']
def __init__(self, config, add_pooling_layer=True):
"""
add_pooling_layer (bool, *optional*, defaults to `True`):
Whether to add a pooling layer
"""
super().__init__... | import torch
import torch.nn as nn
from ...modeling_attn_mask_utils import _prepare_4d_attention_mask_for_sdpa, _prepare_4d_causal_attention_mask_for_sdpa
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithPastAndCros... | 5 | 0 | 3 | 0.4 | true | mrahman2025/OpenClassGen | [] | ||
51 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_roberta.py | modeling_roberta.RobertaPooler | import torch
import torch.nn as nn
class RobertaPooler(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.activation = nn.Tanh()
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
first_to... | """Implement class RobertaPooler.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, hidden_states: torch.Tensor)`"""
import torch
import torch.nn as nn
class RobertaPooler: |
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.activation = nn.Tanh()
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
first_token_tensor = hidden_states[:, 0]
pooled_output = self.dense(... | import torch
import torch.nn as nn | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
52 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_roberta.py | modeling_roberta.RobertaPreTrainedModel | import torch.nn as nn
from ...modeling_utils import PreTrainedModel
from .configuration_roberta import RobertaConfig
from ...utils import auto_docstring, logging
@auto_docstring
class RobertaPreTrainedModel(PreTrainedModel):
config: RobertaConfig
base_model_prefix = 'roberta'
supports_gradient_checkpointin... | """Implement class RobertaPreTrainedModel.
Required methods (implement on the class; order is not specified):
- `_init_weights(self, module)`: Initialize the weights"""
import torch.nn as nn
from ...modeling_utils import PreTrainedModel
from .configuration_roberta import RobertaConfig
from ...utils import auto_docstri... | class RobertaPreTrainedModel(PreTrainedModel):
config: RobertaConfig
base_model_prefix = 'roberta'
supports_gradient_checkpointing = True
_supports_sdpa = True
def _init_weights(self, module):
"""Initialize the weights"""
if isinstance(module, nn.Linear):
module.weight.d... | import torch.nn as nn
from ...modeling_utils import PreTrainedModel
from .configuration_roberta import RobertaConfig
from ...utils import auto_docstring, logging | 1 | 0 | 1 | 1 | true | mrahman2025/OpenClassGen | [] | ||
53 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_roberta.py | modeling_roberta.RobertaSdpaSelfAttention | from typing import Optional, Union
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
import torch
import torch.nn as nn
from ...utils.deprecation import deprecate_kwarg
class RobertaSdpaSelfAttention(RobertaSelfAttention):
def __init__(self, config, position_embedding_type=None, layer_idx=None):... | """Implement class RobertaSdpaSelfAttention.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, position_embedding_type=None, layer_idx=None)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, head_mask: Optional[torch.FloatTensor]=None... |
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super().__init__(config, position_embedding_type=position_embedding_type, layer_idx=layer_idx)
self.dropout_prob = config.attention_probs_dropout_prob
@deprecate_kwarg('past_key_value', new_name='past_key_values', versio... | from typing import Optional, Union
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
import torch
import torch.nn as nn
from ...utils.deprecation import deprecate_kwarg | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
54 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_roberta.py | modeling_roberta.RobertaSelfAttention | from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
import math
import torch.nn as nn
from ...utils.deprecation import deprecate_kwarg
import torch
class RobertaSelfAttention(nn.Module):
def __init__(self, config, position_embedding_type=None, layer_idx=None):
... | """Implement class RobertaSelfAttention.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, position_embedding_type=None, layer_idx=None)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=Non... |
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super().__init__()
if config.hidden_size % config.num_attention_heads != 0 and (not hasattr(config, 'embedding_size')):
raise ValueError(f'The hidden size ({config.hidden_size}) is not a multiple of the number of ... | from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
import math
import torch.nn as nn
from ...utils.deprecation import deprecate_kwarg
import torch | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
55 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_super.py | modeling_super.SuperAttention | from typing import Callable, Optional, Union
from ...processing_utils import Unpack
from ...utils import TransformersKwargs, auto_docstring
import torch
from ...utils.deprecation import deprecate_kwarg
from torch import nn
from ...cache_utils import Cache
from .configuration_super import SuperConfig
from ...modeling_ut... | """Multi-headed attention from 'Attention Is All You Need' paper
Required methods (implement on the class; order is not specified):
- `__init__(self, config: SuperConfig, layer_idx: int)`
- `forward(self, hidden_states: torch.Tensor, position_embeddings: tuple[torch.Tensor, torch.Tensor], attention_mask: Optional[torc... | """Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config: SuperConfig, layer_idx: int):
super().__init__()
self.config = config
self.layer_idx = layer_idx
self.head_dim = getattr(config, 'head_dim', config.hidden_size // config.num_attention_... | from typing import Callable, Optional, Union
from ...processing_utils import Unpack
from ...utils import TransformersKwargs, auto_docstring
import torch
from ...utils.deprecation import deprecate_kwarg
from torch import nn
from ...cache_utils import Cache
from .configuration_super import SuperConfig
from ...modeling_ut... | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
56 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_super.py | modeling_super.SuperDecoderLayer | from ...modeling_layers import GradientCheckpointingLayer
from ...cache_utils import Cache
from ...utils import TransformersKwargs, auto_docstring
import torch
from typing import Callable, Optional, Union
from .configuration_super import SuperConfig
from ...processing_utils import Unpack
from ...utils.deprecation impor... | """Implement class SuperDecoderLayer.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: SuperConfig, layer_idx: int)`
- `forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, position_ids: Optional[torch.LongTensor]=None, past_key_values: Opt... |
def __init__(self, config: SuperConfig, layer_idx: int):
super().__init__()
self.hidden_size = config.hidden_size
self.self_attn = SuperAttention(config=config, layer_idx=layer_idx)
self.mlp = SuperMLP(config)
self.input_layernorm = SuperRMSNorm(config.hidden_size, eps=confi... | from ...modeling_layers import GradientCheckpointingLayer
from ...cache_utils import Cache
from ...utils import TransformersKwargs, auto_docstring
import torch
from typing import Callable, Optional, Union
from .configuration_super import SuperConfig
from ...processing_utils import Unpack
from ...utils.deprecation impor... | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
57 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_super.py | modeling_super.SuperMLP | from torch import nn
from ...activations import ACT2FN
class SuperMLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.hidden_size = config.hidden_size
self.intermediate_size = config.intermediate_size
self.gate_proj = nn.Linear(self.hidd... | """Implement class SuperMLP.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, x)`"""
from torch import nn
from ...activations import ACT2FN
class SuperMLP: |
def __init__(self, config):
super().__init__()
self.config = config
self.hidden_size = config.hidden_size
self.intermediate_size = config.intermediate_size
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
self.up_proj = nn.Li... | from torch import nn
from ...activations import ACT2FN | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
58 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_super.py | modeling_super.SuperModel | from torch import nn
from ...cache_utils import Cache
from typing import Callable, Optional, Union
from transformers.modeling_outputs import CausalLMOutputWithPast
from ...utils.generic import check_model_inputs
from ...utils import TransformersKwargs, auto_docstring
from .configuration_super import SuperConfig
import ... | """Implement class SuperModel.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: SuperConfig)`
- `forward(self, input_ids: torch.LongTensor=None, attention_mask: Optional[torch.Tensor]=None, position_ids: Optional[torch.LongTensor]=None, past_key_values: Optional[Union[Cache,... | class SuperModel(SuperPreTrainedModel):
def __init__(self, config: SuperConfig):
super().__init__(config)
self.padding_idx = config.pad_token_id
self.vocab_size = config.vocab_size
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
self... | from torch import nn
from ...cache_utils import Cache
from typing import Callable, Optional, Union
from transformers.modeling_outputs import CausalLMOutputWithPast
from ...utils.generic import check_model_inputs
from ...utils import TransformersKwargs, auto_docstring
from .configuration_super import SuperConfig
import ... | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
59 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_super.py | modeling_super.SuperPreTrainedModel | from ...utils import TransformersKwargs, auto_docstring
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_super import SuperConfig
@auto_docstring
class SuperPreTrainedModel(PreTrainedModel):
config: SuperConfig
base_model_prefix = 'model'
supports_gradient_checkpoi... | """Implement class SuperPreTrainedModel.
Required methods (implement on the class; order is not specified):
"""
from ...utils import TransformersKwargs, auto_docstring
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_super import SuperConfig
class SuperPreTrainedModel: | class SuperPreTrainedModel(PreTrainedModel):
config: SuperConfig
base_model_prefix = 'model'
supports_gradient_checkpointing = True
_no_split_modules = ['SuperDecoderLayer']
_skip_keys_device_placement = ['past_key_values']
_supports_flash_attn = True
_supports_sdpa = True
_supports_flex... | from ...utils import TransformersKwargs, auto_docstring
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_super import SuperConfig | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
60 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_super.py | modeling_super.SuperRMSNorm | from ...integrations import use_kernel_forward_from_hub
import torch
from torch import nn
@use_kernel_forward_from_hub('RMSNorm')
class SuperRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
"""
SuperRMSNorm is equivalent to T5LayerNorm
"""
super().__init__()
... | """Implement class SuperRMSNorm.
Required methods (implement on the class; order is not specified):
- `__init__(self, hidden_size, eps=1e-06)`: SuperRMSNorm is equivalent to T5LayerNorm
- `forward(self, hidden_states)`
- `extra_repr(self)`"""
from ...integrations import use_kernel_forward_from_hub
import torch
from to... | class SuperRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
"""
SuperRMSNorm is equivalent to T5LayerNorm
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.variance_epsilon = eps
def forward(self, hidden_states):
... | from ...integrations import use_kernel_forward_from_hub
import torch
from torch import nn | 3 | 0 | 3 | 0.333333 | true | mrahman2025/OpenClassGen | [] | ||
61 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_super.py | modeling_super.SuperRotaryEmbedding | from .configuration_super import SuperConfig
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
import torch
from torch import nn
class SuperRotaryEmbedding(nn.Module):
inv_freq: torch.Tensor
def __init__(self, config: SuperConfig, device=None):
super().__init__()
if h... | """Implement class SuperRotaryEmbedding.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: SuperConfig, device=None)`
- `forward(self, x, position_ids)`"""
from .configuration_super import SuperConfig
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update... | inv_freq: torch.Tensor
def __init__(self, config: SuperConfig, device=None):
super().__init__()
if hasattr(config, 'rope_scaling') and isinstance(config.rope_scaling, dict):
self.rope_type = config.rope_scaling.get('rope_type', config.rope_scaling.get('type'))
else:
... | from .configuration_super import SuperConfig
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
import torch
from torch import nn | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
62 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modeling_switch_function.py | modeling_switch_function.SwitchFunctionAttention | from ...utils.deprecation import deprecate_kwarg
from ...processing_utils import Unpack
from ...utils import TransformersKwargs
import torch
from .configuration_switch_function import SwitchFunctionConfig
from ...cache_utils import Cache
from torch import nn
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS
from ty... | """Multi-headed attention from 'Attention Is All You Need' paper
Required methods (implement on the class; order is not specified):
- `__init__(self, config: SwitchFunctionConfig, layer_idx: int)`
- `forward(self, hidden_states: torch.Tensor, position_embeddings: tuple[torch.Tensor, torch.Tensor], attention_mask: Opti... | """Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config: SwitchFunctionConfig, layer_idx: int):
super().__init__()
self.config = config
self.layer_idx = layer_idx
self.head_dim = getattr(config, 'head_dim', config.hidden_size // config.num_a... | from ...utils.deprecation import deprecate_kwarg
from ...processing_utils import Unpack
from ...utils import TransformersKwargs
import torch
from .configuration_switch_function import SwitchFunctionConfig
from ...cache_utils import Cache
from torch import nn
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS
from ty... | 2 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
63 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/utils/models_to_deprecate.py | models_to_deprecate.HubModelLister | class HubModelLister:
"""
Utility for getting models from the hub based on tags. Handles errors without crashing the script.
"""
def __init__(self, tags):
self.tags = tags
self.model_list = api.list_models(tags=tags)
def __iter__(self):
try:
yield from self.mode... | """Utility for getting models from the hub based on tags. Handles errors without crashing the script.
Required methods (implement on the class; order is not specified):
- `__init__(self, tags)`
- `__iter__(self)`"""
class HubModelLister: | """
Utility for getting models from the hub based on tags. Handles errors without crashing the script.
"""
def __init__(self, tags):
self.tags = tags
self.model_list = api.list_models(tags=tags)
def __iter__(self):
try:
yield from self.model_list
except ... | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | |||
64 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_add_function.py | modular_add_function.TestAttention | from transformers.models.zamba.modeling_zamba import ZambaAttention
from transformers.models.llama.modeling_llama import apply_rotary_pos_emb
class TestAttention(ZambaAttention):
def __init__(self):
pass
def forward(self):
_ = apply_rotary_pos_emb(1, 1, 1, 1) | """Implement class TestAttention.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `forward(self)`"""
from transformers.models.zamba.modeling_zamba import ZambaAttention
from transformers.models.llama.modeling_llama import apply_rotary_pos_emb
class TestAttention: |
def __init__(self):
pass
def forward(self):
_ = apply_rotary_pos_emb(1, 1, 1, 1)
| from transformers.models.zamba.modeling_zamba import ZambaAttention
from transformers.models.llama.modeling_llama import apply_rotary_pos_emb | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
65 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_dummy_bert.py | modular_dummy_bert.DummyBertModel | from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithPoolingAndCrossAttentions
import torch
from transformers.models.bert.modeling_bert import BertModel
class DummyBertModel(BertModel):
def forward(self, input_ids: Optional[torch.Tensor]=None, attention_mask: Optional[torch.Tensor... | """Implement class DummyBertModel.
Required methods (implement on the class; order is not specified):
- `forward(self, input_ids: Optional[torch.Tensor]=None, attention_mask: Optional[torch.Tensor]=None, token_type_ids: Optional[torch.Tensor]=None, position_ids: Optional[torch.Tensor]=None, head_mask: Optional[torch.T... |
def forward(self, input_ids: Optional[torch.Tensor]=None, attention_mask: Optional[torch.Tensor]=None, token_type_ids: Optional[torch.Tensor]=None, position_ids: Optional[torch.Tensor]=None, head_mask: Optional[torch.Tensor]=None, inputs_embeds: Optional[torch.Tensor]=None, encoder_hidden_states: Optional[torch.Te... | from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithPoolingAndCrossAttentions
import torch
from transformers.models.bert.modeling_bert import BertModel | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
66 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_from_uppercase_model.py | modular_from_uppercase_model.FromUppercaseModelEncoderLayer | from transformers.models.clip.modeling_clip import CLIPEncoderLayer
class FromUppercaseModelEncoderLayer(CLIPEncoderLayer):
pass | """Implement class FromUppercaseModelEncoderLayer.
Required methods (implement on the class; order is not specified):
"""
from transformers.models.clip.modeling_clip import CLIPEncoderLayer
class FromUppercaseModelEncoderLayer: | pass
| from transformers.models.clip.modeling_clip import CLIPEncoderLayer | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
67 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/utils/modular_model_converter.py | modular_model_converter.ClassDependencyMapper | from libcst import ClassDef, CSTVisitor
from typing import Optional, Union
class ClassDependencyMapper(CSTVisitor):
"""A visitor which is designed to analyze a single class node to get all its dependencies that are shared with the set of
`global_names`.
"""
def __init__(self, class_name: str, global_n... | """A visitor which is designed to analyze a single class node to get all its dependencies that are shared with the set of
`global_names`.
Required methods (implement on the class; order is not specified):
- `__init__(self, class_name: str, global_names: set[str], objects_imported_from_modeling: Optional[set[str]]=None... | """A visitor which is designed to analyze a single class node to get all its dependencies that are shared with the set of
`global_names`.
"""
def __init__(self, class_name: str, global_names: set[str], objects_imported_from_modeling: Optional[set[str]]=None):
super().__init__()
self.cla... | from libcst import ClassDef, CSTVisitor
from typing import Optional, Union | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
68 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/utils/modular_model_converter.py | modular_model_converter.ModelFileMapper | from libcst.metadata import MetadataWrapper, ParentNodeProvider, PositionProvider, ScopeProvider
import libcst as cst
import re
class ModelFileMapper(ModuleMapper):
"""A mapper designed to parse modeling files (like `modeling_llama.py`). When encountering such a file
in the `modular_xxx.py` file, we need to co... | """A mapper designed to parse modeling files (like `modeling_llama.py`). When encountering such a file
in the `modular_xxx.py` file, we need to correctly visit it and merge the dependencies of the modular and current file.
For this reason, this class should only be instantiated from the class method `visit_and_merge_de... | """A mapper designed to parse modeling files (like `modeling_llama.py`). When encountering such a file
in the `modular_xxx.py` file, we need to correctly visit it and merge the dependencies of the modular and current file.
For this reason, this class should only be instantiated from the class method `visit_... | from libcst.metadata import MetadataWrapper, ParentNodeProvider, PositionProvider, ScopeProvider
import libcst as cst
import re | 7 | 3 | 6 | 0.714286 | true | mrahman2025/OpenClassGen | [] | ||
69 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/utils/modular_model_converter.py | modular_model_converter.ModularFileMapper | from collections import Counter, defaultdict, deque
import libcst as cst
import re
from libcst import matchers as m
class ModularFileMapper(ModuleMapper):
"""This is a Mapper to visit a modular file (like `modular_llama.py`). It visits the whole file, recording dependency,
then visits all imported modeling fil... | """This is a Mapper to visit a modular file (like `modular_llama.py`). It visits the whole file, recording dependency,
then visits all imported modeling files (like `modeling_llama.py`), and manages their mutual dependencies.
Calling the method `create_modules()` after visit will create all modules based on this modula... | """This is a Mapper to visit a modular file (like `modular_llama.py`). It visits the whole file, recording dependency,
then visits all imported modeling files (like `modeling_llama.py`), and manages their mutual dependencies.
Calling the method `create_modules()` after visit will create all modules based on... | from collections import Counter, defaultdict, deque
import libcst as cst
import re
from libcst import matchers as m | 7 | 2 | 4 | 0.857143 | true | mrahman2025/OpenClassGen | [] | ||
70 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/utils/modular_model_converter.py | modular_model_converter.ModuleMapper | from libcst.metadata import MetadataWrapper, ParentNodeProvider, PositionProvider, ScopeProvider
import re
from libcst import matchers as m
from libcst import ClassDef, CSTVisitor
from collections import Counter, defaultdict, deque
from abc import ABC, abstractmethod
import libcst as cst
class ModuleMapper(CSTVisitor,... | """An abstract visitor class which analyses a module, creating a mapping of dependencies for classes, functions and assignments.
Class dependencies are computed with `compute_class_dependencies()`, while function and assignment dependencies are stored in
`self.object_recursive_dependency_mapping` (can be computed by `_... | """An abstract visitor class which analyses a module, creating a mapping of dependencies for classes, functions and assignments.
Class dependencies are computed with `compute_class_dependencies()`, while function and assignment dependencies are stored in
`self.object_recursive_dependency_mapping` (can be co... | from libcst.metadata import MetadataWrapper, ParentNodeProvider, PositionProvider, ScopeProvider
import re
from libcst import matchers as m
from libcst import ClassDef, CSTVisitor
from collections import Counter, defaultdict, deque
from abc import ABC, abstractmethod
import libcst as cst | 16 | 1 | 11 | 0.5625 | true | mrahman2025/OpenClassGen | [] | ||
71 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/utils/modular_model_converter.py | modular_model_converter.ReplaceNameTransformer | import libcst as cst
import re
from libcst import matchers as m
class ReplaceNameTransformer(m.MatcherDecoratableTransformer):
"""A transformer that replaces `old_name` with `new_name` in comments, string and any references.
It should take into account name like `MyNewModel`, or `my_new_model`. Without using t... | """A transformer that replaces `old_name` with `new_name` in comments, string and any references.
It should take into account name like `MyNewModel`, or `my_new_model`. Without using the AUTO_MAPPING.
Supported renaming patterns:
- llama -> my_new_model and my_new_model -> llama
- Llama -> MyNewModel... | """A transformer that replaces `old_name` with `new_name` in comments, string and any references.
It should take into account name like `MyNewModel`, or `my_new_model`. Without using the AUTO_MAPPING.
Supported renaming patterns:
- llama -> my_new_model and my_new_model -> llama
-... | import libcst as cst
import re
from libcst import matchers as m | 5 | 2 | 3 | 0.2 | true | mrahman2025/OpenClassGen | [] | ||
72 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_multimodal2.py | modular_multimodal2.Multimodal2VisionAttention | from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
class Multimodal2VisionAttention(CLIPAttention):
pass | """Implement class Multimodal2VisionAttention.
Required methods (implement on the class; order is not specified):
"""
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
class Multimodal2VisionAttention: | pass
| from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
73 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_multimodal2.py | modular_multimodal2.Multimodal2VisionEncoder | from torch import nn
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
class Multimodal2VisionEncoder(CLIPEncoder):
def __init__(self, config):
super().__init__(config)
self.layers =... | """Implement class Multimodal2VisionEncoder.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`"""
from torch import nn
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTr... |
def __init__(self, config):
super().__init__(config)
self.layers = nn.ModuleList([Multimodal2VisionEncoderLayer(config) for _ in range(config.num_hidden_layers)])
| from torch import nn
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
74 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_multimodal2.py | modular_multimodal2.Multimodal2VisionEncoderLayer | from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
class Multimodal2VisionEncoderLayer(CLIPEncoderLayer):
def __init__(self, config):
super().__init__()
self.mlp = Multimodal2VisionML... | """Implement class Multimodal2VisionEncoderLayer.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`"""
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
class... |
def __init__(self, config):
super().__init__()
self.mlp = Multimodal2VisionMLP(config)
| from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
75 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_multimodal2.py | modular_multimodal2.Multimodal2VisionMLP | from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
class Multimodal2VisionMLP(CLIPMLP):
pass | """Implement class Multimodal2VisionMLP.
Required methods (implement on the class; order is not specified):
"""
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
class Multimodal2VisionMLP: | pass
| from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
76 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_multimodal2.py | modular_multimodal2.Multimodal2VisionModel | from transformers.utils import add_start_docstrings
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
@add_start_docstrings('New doc', MULTIMODAL2_VISION_START_DOCSTRING)
class Multimodal2VisionModel(CLI... | """Implement class Multimodal2VisionModel.
Required methods (implement on the class; order is not specified):
"""
from transformers.utils import add_start_docstrings
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisio... | class Multimodal2VisionModel(CLIPVisionModel, Multimodal2VisionPreTrainedModel):
_no_split_modules = ['Multimodal2VisionEncoderLayer']
| from transformers.utils import add_start_docstrings
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
77 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_multimodal2.py | modular_multimodal2.Multimodal2VisionPreTrainedModel | from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
class Multimodal2VisionPreTrainedModel(CLIPPreTrainedModel):
def _init_weights(self, module):
if isinstance(module, Multimodal2VisionMLP):
... | """Implement class Multimodal2VisionPreTrainedModel.
Required methods (implement on the class; order is not specified):
- `_init_weights(self, module)`"""
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransforme... |
def _init_weights(self, module):
if isinstance(module, Multimodal2VisionMLP):
pass
| from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
78 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_multimodal2.py | modular_multimodal2.Multimodal2VisionTransformer | from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
class Multimodal2VisionTransformer(CLIPVisionTransformer):
def __init__(self, config):
super().__init__(config)
self.encoder = Multi... | """Implement class Multimodal2VisionTransformer.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`"""
from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer
class ... |
def __init__(self, config):
super().__init__(config)
self.encoder = Multimodal2VisionEncoder(config)
| from transformers.models.clip.modeling_clip import CLIPMLP, CLIPAttention, CLIPEncoder, CLIPEncoderLayer, CLIPPreTrainedModel, CLIPVisionModel, CLIPVisionTransformer | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
79 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_my_new_model.py | modular_my_new_model.MyNewModelConfig | from transformers.models.llama.configuration_llama import LlamaConfig
class MyNewModelConfig(LlamaConfig):
"""
This is the configuration class to store the configuration of a [`MyNewModelModel`]. It is used to instantiate an MyNewModel
model according to the specified arguments, defining the model architec... | """This is the configuration class to store the configuration of a [`MyNewModelModel`]. It is used to instantiate an MyNewModel
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the MyNewModel-7B.
e.... | """
This is the configuration class to store the configuration of a [`MyNewModelModel`]. It is used to instantiate an MyNewModel
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the ... | from transformers.models.llama.configuration_llama import LlamaConfig | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
80 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_my_new_model2.py | modular_my_new_model2.MyNewModel2Config | from transformers.models.llama.configuration_llama import LlamaConfig
class MyNewModel2Config(LlamaConfig):
"""
This is the configuration class to store the configuration of a [`GemmaModel`]. It is used to instantiate an Gemma
model according to the specified arguments, defining the model architecture. Ins... | """This is the configuration class to store the configuration of a [`GemmaModel`]. It is used to instantiate an Gemma
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the Gemma-7B.
e.g. [google/gemm... | """
This is the configuration class to store the configuration of a [`GemmaModel`]. It is used to instantiate an Gemma
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the Gemma-7B.
... | from transformers.models.llama.configuration_llama import LlamaConfig | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
81 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_my_new_model2.py | modular_my_new_model2.MyNewModel2ForSequenceClassification | from transformers.models.gemma.modeling_gemma import GemmaForSequenceClassification
class MyNewModel2ForSequenceClassification(GemmaForSequenceClassification):
pass | """Implement class MyNewModel2ForSequenceClassification.
Required methods (implement on the class; order is not specified):
"""
from transformers.models.gemma.modeling_gemma import GemmaForSequenceClassification
class MyNewModel2ForSequenceClassification: | pass
| from transformers.models.gemma.modeling_gemma import GemmaForSequenceClassification | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
82 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_new_imgproc_model.py | modular_new_imgproc_model.ImgprocModelImageProcessor | import torch
from transformers.models.blip.image_processing_blip import BlipImageProcessor
import torch.utils.checkpoint
class ImgprocModelImageProcessor(BlipImageProcessor):
def new_image_processing_method(self, pixel_values: torch.FloatTensor):
return pixel_values / 2 | """Implement class ImgprocModelImageProcessor.
Required methods (implement on the class; order is not specified):
- `new_image_processing_method(self, pixel_values: torch.FloatTensor)`"""
import torch
from transformers.models.blip.image_processing_blip import BlipImageProcessor
import torch.utils.checkpoint
class Img... |
def new_image_processing_method(self, pixel_values: torch.FloatTensor):
return pixel_values / 2
| import torch
from transformers.models.blip.image_processing_blip import BlipImageProcessor
import torch.utils.checkpoint | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
83 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_new_model.py | modular_new_model.NewModelConfig | from transformers.models.gemma.configuration_gemma import GemmaConfig
class NewModelConfig(GemmaConfig):
def __init__(self, vocab_size=256030, hidden_size=64, intermediate_size=90, num_hidden_layers=28, num_attention_heads=16, num_key_value_heads=16, head_dim=256, hidden_act='gelu_pytorch_tanh', hidden_activation... | """Implement class NewModelConfig.
Required methods (implement on the class; order is not specified):
- `__init__(self, vocab_size=256030, hidden_size=64, intermediate_size=90, num_hidden_layers=28, num_attention_heads=16, num_key_value_heads=16, head_dim=256, hidden_act='gelu_pytorch_tanh', hidden_activation=None, ma... |
def __init__(self, vocab_size=256030, hidden_size=64, intermediate_size=90, num_hidden_layers=28, num_attention_heads=16, num_key_value_heads=16, head_dim=256, hidden_act='gelu_pytorch_tanh', hidden_activation=None, max_position_embeddings=1500, initializer_range=0.02, rms_norm_eps=1e-06, use_cache=True, pad_token... | from transformers.models.gemma.configuration_gemma import GemmaConfig | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
84 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_new_task_model.py | modular_new_task_model.NewTaskModelForNewTask | import torch.utils.checkpoint
from typing import ClassVar, Optional, Union
import torch
from transformers.models.paligemma.modeling_paligemma import PaliGemmaForConditionalGeneration
from ...cache_utils import Cache
from torch import nn
class NewTaskModelForNewTask(PaliGemmaForConditionalGeneration):
main_input_na... | """Implement class NewTaskModelForNewTask.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`
- `forward(self, input_ids: torch.LongTensor=None, pixel_values: torch.FloatTensor=None, attention_mask: Optional[torch.Tensor]=None, position_ids: Optional[torch.LongTensor]=None, p... | main_input_name: ClassVar[str] = 'doc_input_ids'
def __init__(self, config):
super().__init__(config=config)
self.embedding_dim = self.config.embedding_dim
self.custom_text_proj = nn.Linear(self.config.text_config.hidden_size, self.embedding_dim)
if self.language_model._tied_wei... | import torch.utils.checkpoint
from typing import ClassVar, Optional, Union
import torch
from transformers.models.paligemma.modeling_paligemma import PaliGemmaForConditionalGeneration
from ...cache_utils import Cache
from torch import nn | 3 | 0 | 1 | 0.333333 | true | mrahman2025/OpenClassGen | [] | ||
85 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_roberta.py | modular_roberta.RobertaEmbeddings | import torch.nn as nn
from transformers.models.bert.modeling_bert import BertEmbeddings, BertModel
class RobertaEmbeddings(BertEmbeddings):
def __init__(self, config):
super().__init__(config)
self.pad_token_id = config.pad_token_id
self.position_embeddings = nn.Embedding(config.max_positi... | """Implement class RobertaEmbeddings.
Required methods (implement on the class; order is not specified):
- `__init__(self, config)`"""
import torch.nn as nn
from transformers.models.bert.modeling_bert import BertEmbeddings, BertModel
class RobertaEmbeddings: |
def __init__(self, config):
super().__init__(config)
self.pad_token_id = config.pad_token_id
self.position_embeddings = nn.Embedding(config.max_position_embeddings, config.hidden_size, config.pad_token_id)
| import torch.nn as nn
from transformers.models.bert.modeling_bert import BertEmbeddings, BertModel | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
86 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_roberta.py | modular_roberta.RobertaModel | from transformers.models.bert.modeling_bert import BertEmbeddings, BertModel
class RobertaModel(BertModel):
def __init__(self, config, add_pooling_layer=True):
super().__init__(self, config) | """Implement class RobertaModel.
Required methods (implement on the class; order is not specified):
- `__init__(self, config, add_pooling_layer=True)`"""
from transformers.models.bert.modeling_bert import BertEmbeddings, BertModel
class RobertaModel: |
def __init__(self, config, add_pooling_layer=True):
super().__init__(self, config)
| from transformers.models.bert.modeling_bert import BertEmbeddings, BertModel | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
87 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_super.py | modular_super.SuperModel | from typing import Optional, Union
from ...cache_utils import Cache
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.models.llama.modeling_llama import LlamaModel
import torch
class SuperModel(LlamaModel):
def forward(self, input_ids: torch.LongTensor=None, attention_mask: Option... | """Implement class SuperModel.
Required methods (implement on the class; order is not specified):
- `forward(self, input_ids: torch.LongTensor=None, attention_mask: Optional[torch.Tensor]=None, position_ids: Optional[torch.LongTensor]=None, past_key_values: Optional[Union[Cache, list[torch.FloatTensor]]]=None, inputs_... |
def forward(self, input_ids: torch.LongTensor=None, attention_mask: Optional[torch.Tensor]=None, position_ids: Optional[torch.LongTensor]=None, past_key_values: Optional[Union[Cache, list[torch.FloatTensor]]]=None, inputs_embeds: Optional[torch.FloatTensor]=None, use_cache: Optional[bool]=None, output_attentions: ... | from typing import Optional, Union
from ...cache_utils import Cache
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.models.llama.modeling_llama import LlamaModel
import torch | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
88 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/modular-transformers/modular_switch_function.py | modular_switch_function.SwitchFunctionAttention | from transformers.models.llama.modeling_llama import LlamaAttention
class SwitchFunctionAttention(LlamaAttention):
pass | """Implement class SwitchFunctionAttention.
Required methods (implement on the class; order is not specified):
"""
from transformers.models.llama.modeling_llama import LlamaAttention
class SwitchFunctionAttention: | pass
| from transformers.models.llama.modeling_llama import LlamaAttention | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
89 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/utils/notification_service.py | notification_service.Message | import re
import os
from typing import Any, Optional, Union
import json
import time
class Message:
def __init__(self, title: str, ci_title: str, model_results: dict, additional_results: dict, selected_warnings: Optional[list]=None, prev_ci_artifacts=None, other_ci_artifacts=None):
self.title = title
... | """Implement class Message.
Required methods (implement on the class; order is not specified):
- `__init__(self, title: str, ci_title: str, model_results: dict, additional_results: dict, selected_warnings: Optional[list]=None, prev_ci_artifacts=None, other_ci_artifacts=None)`
- `time(self)`
- `header(self)`
- `ci_titl... |
def __init__(self, title: str, ci_title: str, model_results: dict, additional_results: dict, selected_warnings: Optional[list]=None, prev_ci_artifacts=None, other_ci_artifacts=None):
self.title = title
self.ci_title = ci_title
self.n_model_success = sum((r['success'] for r in model_results.... | import re
import os
from typing import Any, Optional, Union
import json
import time | 18 | 6 | 13 | 0.055556 | true | mrahman2025/OpenClassGen | [] | ||
90 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/benchmarking/plot_csv_file.py | plot_csv_file.Plot | import matplotlib.pyplot as plt
import numpy as np
import csv
from matplotlib.ticker import ScalarFormatter
from collections import defaultdict
class Plot:
def __init__(self, args):
self.args = args
self.result_dict = defaultdict(lambda: {'bsz': [], 'seq_len': [], 'result': {}})
with open(... | """Implement class Plot.
Required methods (implement on the class; order is not specified):
- `__init__(self, args)`
- `plot(self)`"""
import matplotlib.pyplot as plt
import numpy as np
import csv
from matplotlib.ticker import ScalarFormatter
from collections import defaultdict
class Plot: |
def __init__(self, args):
self.args = args
self.result_dict = defaultdict(lambda: {'bsz': [], 'seq_len': [], 'result': {}})
with open(self.args.csv_file, newline='') as csv_file:
reader = csv.DictReader(csv_file)
for row in reader:
model_name = row['m... | import matplotlib.pyplot as plt
import numpy as np
import csv
from matplotlib.ticker import ScalarFormatter
from collections import defaultdict | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
91 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/benchmarking/plot_csv_file.py | plot_csv_file.PlotArguments | from dataclasses import dataclass, field
from typing import Optional
@dataclass
class PlotArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
"""
csv_file: str = field(metadata={'help': 'The csv file to plot.'})
plot_along_batch: boo... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
Required methods (implement on the class; order is not specified):
"""
from dataclasses import dataclass, field
from typing import Optional
class PlotArguments: | class PlotArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
"""
csv_file: str = field(metadata={'help': 'The csv file to plot.'})
plot_along_batch: bool = field(default=False, metadata={'help': 'Whether to plot along batch size or s... | from dataclasses import dataclass, field
from typing import Optional | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
92 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/audio-classification/run_audio_classification.py | run_audio_classification.ModelArguments | from dataclasses import dataclass, field
import warnings
from typing import Optional
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(default='facebook/wav2vec2-base', metadata={'help': 'Path to... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
- `__post_init__(self)`"""
from dataclasses import dataclass, field
import warnings
from typing import Optional
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(default='facebook/wav2vec2-base', metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str... | from dataclasses import dataclass, field
import warnings
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
93 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/text-classification/run_classification.py | run_classification.DataTrainingArguments | from dataclasses import dataclass, field
from typing import Optional
@dataclass
class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
Using `HfArgumentParser` we can turn this class
into argparse arguments to be able to specify them o... | """Arguments pertaining to what data we are going to input our model for training and eval.
Using `HfArgumentParser` we can turn this class
into argparse arguments to be able to specify them on
the command line.
Required methods (implement on the class; order is not specified):
- `__post_init__(self)`"""
from datacla... | class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
Using `HfArgumentParser` we can turn this class
into argparse arguments to be able to specify them on
the command line.
"""
dataset_name: Optional[str] = field(default=N... | from dataclasses import dataclass, field
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
94 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/contrastive-image-text/run_clip.py | run_clip.DataTrainingArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
dataset_name: Optional[str] = field(default=None, metadata={'help': 'The name of the dataset to u... | """Arguments pertaining to what data we are going to input our model for training and eval.
Required methods (implement on the class; order is not specified):
- `__post_init__(self)`"""
from typing import Optional
from dataclasses import dataclass, field
class DataTrainingArguments: | class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
dataset_name: Optional[str] = field(default=None, metadata={'help': 'The name of the dataset to use (via the datasets library).'})
dataset_config_name: Optional[str] = field(... | from typing import Optional
from dataclasses import dataclass, field | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
95 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/contrastive-image-text/run_clip.py | run_clip.ModelArguments | from dataclasses import dataclass, field
from typing import Optional
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model ident... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
Required methods (implement on the class; order is not specified):
"""
from dataclasses import dataclass, field
from typing import Optional
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(defaul... | from dataclasses import dataclass, field
from typing import Optional | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
96 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/contrastive-image-text/run_clip.py | run_clip.Transform | import torch
from torchvision.transforms.functional import InterpolationMode
from torchvision.transforms import CenterCrop, ConvertImageDtype, Normalize, Resize
class Transform(torch.nn.Module):
def __init__(self, image_size, mean, std):
super().__init__()
self.transforms = torch.nn.Sequential(Res... | """Implement class Transform.
Required methods (implement on the class; order is not specified):
- `__init__(self, image_size, mean, std)`
- `forward(self, x)`: `x` should be an instance of `PIL.Image.Image`"""
import torch
from torchvision.transforms.functional import InterpolationMode
from torchvision.transforms imp... |
def __init__(self, image_size, mean, std):
super().__init__()
self.transforms = torch.nn.Sequential(Resize([image_size], interpolation=InterpolationMode.BICUBIC), CenterCrop(image_size), ConvertImageDtype(torch.float), Normalize(mean, std))
def forward(self, x) -> torch.Tensor:
"""`x` ... | import torch
from torchvision.transforms.functional import InterpolationMode
from torchvision.transforms import CenterCrop, ConvertImageDtype, Normalize, Resize | 2 | 0 | 1 | 0.5 | true | mrahman2025/OpenClassGen | [] | ||
97 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/language-modeling/run_clm.py | run_clm.DataTrainingArguments | from dataclasses import dataclass, field
from transformers.utils.versions import require_version
from typing import Optional
@dataclass
class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
dataset_name: Optional[str] = field(defau... | """Arguments pertaining to what data we are going to input our model for training and eval.
Required methods (implement on the class; order is not specified):
- `__post_init__(self)`"""
from dataclasses import dataclass, field
from transformers.utils.versions import require_version
from typing import Optional
class D... | class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
dataset_name: Optional[str] = field(default=None, metadata={'help': 'The name of the dataset to use (via the datasets library).'})
dataset_config_name: Optional[str] = field(... | from dataclasses import dataclass, field
from transformers.utils.versions import require_version
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
98 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/language-modeling/run_clm.py | run_clm.ModelArguments | from dataclasses import dataclass, field
from typing import Optional
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
"""
model_name_or_path: Optional[str] = field(default=None, metadata={'help': "The model check... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
Required methods (implement on the class; order is not specified):
- `__post_init__(self)`"""
from dataclasses import dataclass, field
from typing import Optional
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
"""
model_name_or_path: Optional[str] = field(default=None, metadata={'help': "The model checkpoint for weights initialization. Don't set if you want to train a model from scr... | from dataclasses import dataclass, field
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
99 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/language-modeling/run_fim.py | run_fim.DataTrainingArguments | from transformers.utils.versions import require_version
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
dataset_name: Optional[str] = field(defau... | """Arguments pertaining to what data we are going to input our model for training and eval.
Required methods (implement on the class; order is not specified):
- `__post_init__(self)`"""
from transformers.utils.versions import require_version
from dataclasses import dataclass, field
from typing import Optional
class D... | class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
dataset_name: Optional[str] = field(default=None, metadata={'help': 'The name of the dataset to use (via the datasets library).'})
dataset_config_name: Optional[str] = field(... | from transformers.utils.versions import require_version
from dataclasses import dataclass, field
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.