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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
100 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/language-modeling/run_fim.py | run_fim.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 | [] | ||
101 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/text-generation/run_generation.py | run_generation._ModelFallbackWrapper | from transformers import AutoTokenizer, BloomForCausalLM, BloomTokenizerFast, CTRLLMHeadModel, CTRLTokenizer, GenerationMixin, GPT2LMHeadModel, GPT2Tokenizer, GPTJForCausalLM, LlamaForCausalLM, OpenAIGPTLMHeadModel, OpenAIGPTTokenizer, OPTForCausalLM, XLMTokenizer, XLMWithLMHeadModel, XLNetLMHeadModel, XLNetTokenizer
i... | """Implement class _ModelFallbackWrapper.
Required methods (implement on the class; order is not specified):
- `__init__(self, optimized, default)`
- `__call__(self, *args, **kwargs)`
- `__getattr__(self, item)`
- `prepare_inputs_for_generation(self, input_ids, past_key_values=None, inputs_embeds=None, use_cache=None,... | __slots__ = ('_optimized', '_default')
def __init__(self, optimized, default):
self._optimized = optimized
self._default = default
def __call__(self, *args, **kwargs):
if kwargs['past_key_values'] is None and self._default.config.use_cache:
kwargs['past_key_values'] = g... | from transformers import AutoTokenizer, BloomForCausalLM, BloomTokenizerFast, CTRLLMHeadModel, CTRLTokenizer, GenerationMixin, GPT2LMHeadModel, GPT2Tokenizer, GPTJForCausalLM, LlamaForCausalLM, OpenAIGPTLMHeadModel, OpenAIGPTTokenizer, OPTForCausalLM, XLMTokenizer, XLMWithLMHeadModel, XLNetLMHeadModel, XLNetTokenizer
i... | 5 | 0 | 4 | 0.2 | true | mrahman2025/OpenClassGen | [] | ||
102 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/text-classification/run_glue.py | run_glue.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.
"""
task_name: Optional[str] = field(default=None... | from dataclasses import dataclass, field
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
103 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/pytorch-lightning/run_glue.py | run_glue.GLUETransformer | from transformers import glue_compute_metrics as compute_metrics
from lightning_base import BaseTransformer, add_generic_args, generic_train
from transformers import glue_convert_examples_to_features as convert_examples_to_features
from transformers import glue_output_modes, glue_tasks_num_labels
import os
from argpars... | """Implement class GLUETransformer.
Required methods (implement on the class; order is not specified):
- `__init__(self, hparams)`
- `forward(self, **inputs)`
- `training_step(self, batch, batch_idx)`
- `prepare_data(self)`: Called to initialize data. Use the call to construct features
- `get_dataloader(self, mode: st... | mode = 'sequence-classification'
def __init__(self, hparams):
if isinstance(hparams, dict):
hparams = Namespace(**hparams)
hparams.glue_output_mode = glue_output_modes[hparams.task]
num_labels = glue_tasks_num_labels[hparams.task]
super().__init__(hparams, num_labels... | from transformers import glue_compute_metrics as compute_metrics
from lightning_base import BaseTransformer, add_generic_args, generic_train
from transformers import glue_convert_examples_to_features as convert_examples_to_features
from transformers import glue_output_modes, glue_tasks_num_labels
import os
from argpars... | 10 | 2 | 5 | 0.2 | true | mrahman2025/OpenClassGen | [] | ||
104 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/text-classification/run_glue.py | run_glue.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
105 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/image-classification/run_image_classification.py | run_image_classification.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.
Using `HfArgumentParser` we can turn this class into argparse arguments to be able to specify
them on... | """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 typing i... | 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=None, ... | from typing import Optional
from dataclasses import dataclass, field | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
106 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/image-classification/run_image_classification.py | run_image_classification.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(default='google/vit-base-patch16-224-in21k', metadata={'help': 'Path to pret... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
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='google/vit-base-patch16-224-in21k', metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
model_type: Op... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
107 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/instance-segmentation/run_instance_segmentation.py | run_instance_segmentation.Evaluator | from torchmetrics.detection.mean_ap import MeanAveragePrecision
from collections.abc import Mapping
from transformers.trainer import EvalPrediction
import torch
from transformers import AutoImageProcessor, AutoModelForUniversalSegmentation, HfArgumentParser, Trainer, TrainingArguments
class Evaluator:
"""
Comp... | """Compute metrics for the instance segmentation task.
Required methods (implement on the class; order is not specified):
- `__init__(self, image_processor: AutoImageProcessor, id2label: Mapping[int, str], threshold: float=0.0)`: Initialize evaluator with image processor, id2label mapping and threshold for filtering p... | """
Compute metrics for the instance segmentation task.
"""
def __init__(self, image_processor: AutoImageProcessor, id2label: Mapping[int, str], threshold: float=0.0):
"""
Initialize evaluator with image processor, id2label mapping and threshold for filtering predictions.
Args:... | from torchmetrics.detection.mean_ap import MeanAveragePrecision
from collections.abc import Mapping
from transformers.trainer import EvalPrediction
import torch
from transformers import AutoImageProcessor, AutoModelForUniversalSegmentation, HfArgumentParser, Trainer, TrainingArguments | 7 | 5 | 5 | 0.571429 | true | mrahman2025/OpenClassGen | [] | ||
108 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/instance-segmentation/run_instance_segmentation.py | run_instance_segmentation.ModelOutput | from dataclasses import dataclass, field
import torch
@dataclass
class ModelOutput:
class_queries_logits: torch.Tensor
masks_queries_logits: torch.Tensor | """Implement class ModelOutput.
Required methods (implement on the class; order is not specified):
"""
from dataclasses import dataclass, field
import torch
class ModelOutput: | class ModelOutput:
class_queries_logits: torch.Tensor
masks_queries_logits: torch.Tensor
| from dataclasses import dataclass, field
import torch | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
109 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/run_language_modeling.py | run_language_modeling.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.
"""
train_data_file: Optional[str] = field(default=None, metadata={'help': 'The input training data f... | """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):
"""
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.
"""
train_data_file: Optional[str] = field(default=None, metadata={'help': 'The input training data file (a text file).'})
train_data_files: Optional[str] = field(default=None, m... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
110 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/run_language_modeling.py | run_language_modeling.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):
"""
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. Leave None if you want to train a model from sc... | from dataclasses import dataclass, field
from typing import Optional | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
111 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/image-pretraining/run_mae.py | run_mae.CustomTrainingArguments | from dataclasses import dataclass, field
from transformers import HfArgumentParser, Trainer, TrainingArguments, ViTImageProcessor, ViTMAEConfig, ViTMAEForPreTraining
@dataclass
class CustomTrainingArguments(TrainingArguments):
base_learning_rate: float = field(default=0.001, metadata={'help': 'Base learning rate: ... | """Implement class CustomTrainingArguments.
Required methods (implement on the class; order is not specified):
"""
from dataclasses import dataclass, field
from transformers import HfArgumentParser, Trainer, TrainingArguments, ViTImageProcessor, ViTMAEConfig, ViTMAEForPreTraining
class CustomTrainingArguments: | class CustomTrainingArguments(TrainingArguments):
base_learning_rate: float = field(default=0.001, metadata={'help': 'Base learning rate: absolute_lr = base_lr * total_batch_size / 256.'})
| from dataclasses import dataclass, field
from transformers import HfArgumentParser, Trainer, TrainingArguments, ViTImageProcessor, ViTMAEConfig, ViTMAEForPreTraining | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
112 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/image-pretraining/run_mae.py | run_mae.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 on... | """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 dataclas... | 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='c... | from dataclasses import dataclass, field
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
113 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/image-pretraining/run_mae.py | run_mae.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/image processor we are going to pre-train.
"""
model_name_or_path: str = field(default=None, metadata={'help': "The model checkpoint for weights initializ... | """Arguments pertaining to which model/config/image processor we are going to pre-train.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/image processor we are going to pre-train.
"""
model_name_or_path: str = field(default=None, metadata={'help': "The model checkpoint for weights initialization. Don't set if you want to train a model from scratch."})
config_name: O... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
114 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/image-pretraining/run_mim.py | run_mim.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.
Using `HfArgumentParser` we can turn this class into argparse arguments to be able to
specify them on... | """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 typing i... | 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='cifar... | from typing import Optional
from dataclasses import dataclass, field | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
115 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/image-pretraining/run_mim.py | run_mim.MaskGenerator | import torch
import numpy as np
class MaskGenerator:
"""
A class to generate boolean masks for the pretraining task.
A mask is a 1D tensor of shape (model_patch_size**2,) where the value is either 0 or 1,
where 1 indicates "masked".
"""
def __init__(self, input_size=192, mask_patch_size=32, m... | """A class to generate boolean masks for the pretraining task.
A mask is a 1D tensor of shape (model_patch_size**2,) where the value is either 0 or 1,
where 1 indicates "masked".
Required methods (implement on the class; order is not specified):
- `__init__(self, input_size=192, mask_patch_size=32, model_patch_size=4... | """
A class to generate boolean masks for the pretraining task.
A mask is a 1D tensor of shape (model_patch_size**2,) where the value is either 0 or 1,
where 1 indicates "masked".
"""
def __init__(self, input_size=192, mask_patch_size=32, model_patch_size=4, mask_ratio=0.6):
self.input... | import torch
import numpy as np | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
116 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/image-pretraining/run_mim.py | run_mim.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/image processor we are going to pre-train.
"""
model_name_or_path: str = field(default=None, metadata={'help': "The model checkpoint for weights initializ... | """Arguments pertaining to which model/config/image processor we are going to pre-train.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/image processor we are going to pre-train.
"""
model_name_or_path: str = field(default=None, metadata={'help': "The model checkpoint for weights initialization. Can be a local path to a pytorch_model.bin or a checkpoint identifier on t... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
117 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/image-pretraining/run_mim_no_trainer.py | run_mim_no_trainer.MaskGenerator | import numpy as np
import torch
class MaskGenerator:
"""
A class to generate boolean masks for the pretraining task.
A mask is a 1D tensor of shape (model_patch_size**2,) where the value is either 0 or 1,
where 1 indicates "masked".
"""
def __init__(self, input_size=192, mask_patch_size=32, m... | """A class to generate boolean masks for the pretraining task.
A mask is a 1D tensor of shape (model_patch_size**2,) where the value is either 0 or 1,
where 1 indicates "masked".
Required methods (implement on the class; order is not specified):
- `__init__(self, input_size=192, mask_patch_size=32, model_patch_size=4... | """
A class to generate boolean masks for the pretraining task.
A mask is a 1D tensor of shape (model_patch_size**2,) where the value is either 0 or 1,
where 1 indicates "masked".
"""
def __init__(self, input_size=192, mask_patch_size=32, model_patch_size=4, mask_ratio=0.6):
self.input... | import numpy as np
import torch | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
118 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/language-modeling/run_mlm.py | run_mlm.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 | [] | ||
119 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/language-modeling/run_mlm.py | run_mlm.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@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 typing import Optional
from dataclasses import dataclass, field
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 typing import Optional
from dataclasses import dataclass, field | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
120 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/multiple_choice/run_multiple_choice.py | run_multiple_choice.DataTrainingArguments | from utils_multiple_choice import MultipleChoiceDataset, Split, processors
from dataclasses import dataclass, field
@dataclass
class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
task_name: str = field(metadata={'help': 'The name... | """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):
"""
from utils_multiple_choice import MultipleChoiceDataset, Split, processors
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.
"""
task_name: str = field(metadata={'help': 'The name of the task to train on: ' + ', '.join(processors.keys())})
data_dir: str = field(metadata={'help': 'Should contain the dat... | from utils_multiple_choice import MultipleChoiceDataset, Split, processors
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
121 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/multiple_choice/run_multiple_choice.py | run_multiple_choice.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 from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
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 from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from dataclasses import dataclass, field
from typing import Optional | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
122 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/token-classification/run_ner.py | run_ner.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.
"""
data_dir: str = field(metadata={'help': 'The input data dir. Should contain the .txt files for a ... | """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):
"""
from dataclasses import dataclass, field
from typing import Optional
class DataTrainingArguments: | class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
data_dir: str = field(metadata={'help': 'The input data dir. Should contain the .txt files for a CoNLL-2003-formatted task.'})
labels: Optional[str] = field(default=None, met... | from dataclasses import dataclass, field
from typing import Optional | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
123 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/token-classification/run_ner.py | run_ner.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.
"""
task_name: Optional[str] = field(default='ner', metadata={'help': 'The name of the task (ner, pos... | """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.
"""
task_name: Optional[str] = field(default='ner', metadata={'help': 'The name of the task (ner, pos...).'})
dataset_name: Optional[str] = field(default=None, metadata={'help': ... | from typing import Optional
from dataclasses import dataclass, field | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
124 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/token-classification/run_ner.py | run_ner.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
125 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/token-classification/run_ner.py | run_ner.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
126 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/pytorch-lightning/run_ner.py | run_ner.NERTransformer | from utils_ner import TokenClassificationTask
from torch.nn import CrossEntropyLoss
import os
import numpy as np
from argparse import Namespace
from importlib import import_module
import torch
from torch.utils.data import DataLoader, TensorDataset
from lightning_base import BaseTransformer, add_generic_args, generic_tr... | """A training module for NER. See BaseTransformer for the core options.
Required methods (implement on the class; order is not specified):
- `__init__(self, hparams)`
- `forward(self, **inputs)`
- `training_step(self, batch, batch_num)`: Compute loss and log.
- `prepare_data(self)`: Called to initialize data. Use the ... | """
A training module for NER. See BaseTransformer for the core options.
"""
mode = 'token-classification'
def __init__(self, hparams):
if isinstance(hparams, dict):
hparams = Namespace(**hparams)
module = import_module('tasks')
try:
token_classificat... | from utils_ner import TokenClassificationTask
from torch.nn import CrossEntropyLoss
import os
import numpy as np
from argparse import Namespace
from importlib import import_module
import torch
from torch.utils.data import DataLoader, TensorDataset
from lightning_base import BaseTransformer, add_generic_args, generic_tr... | 10 | 2 | 5 | 0.5 | true | mrahman2025/OpenClassGen | [] | ||
127 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/object-detection/run_object_detection.py | run_object_detection.ModelArguments | from typing import Any, Optional, Union
from dataclasses import dataclass, field
@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/detr-resnet-50', metadata={'help': 'Path to pr... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Any, Optional, Union
from dataclasses import dataclass, field
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/detr-resnet-50', metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[st... | from typing import Any, Optional, Union
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
128 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/object-detection/run_object_detection.py | run_object_detection.ModelOutput | from dataclasses import dataclass, field
import torch
@dataclass
class ModelOutput:
logits: torch.Tensor
pred_boxes: torch.Tensor | """Implement class ModelOutput.
Required methods (implement on the class; order is not specified):
"""
from dataclasses import dataclass, field
import torch
class ModelOutput: | class ModelOutput:
logits: torch.Tensor
pred_boxes: torch.Tensor
| from dataclasses import dataclass, field
import torch | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
129 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/language-modeling/run_plm.py | run_plm.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 | [] | ||
130 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/language-modeling/run_plm.py | run_plm.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 | [] | ||
131 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/question-answering/run_qa.py | run_qa.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.
"""
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 dataclasses import dataclass, field
from typing import Optional
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 dataclasses import dataclass, field
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
132 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/question-answering/run_qa.py | run_qa.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
133 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/question-answering/run_qa_beam_search.py | run_qa_beam_search.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.
"""
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 dataclasses import dataclass, field
from typing import Optional
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 dataclasses import dataclass, field
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
134 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/question-answering/run_qa_beam_search.py | run_qa_beam_search.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
135 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/semantic-segmentation/run_semantic_segmentation.py | run_semantic_segmentation.DataTrainingArguments | import warnings
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.
Using `HfArgumentParser` we can turn this class into argparse arguments to be able to spe... | """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)`"""
import warnin... | 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='segme... | import warnings
from typing import Optional
from dataclasses import dataclass, field | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
136 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/semantic-segmentation/run_semantic_segmentation.py | run_semantic_segmentation.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(default='nvidia/mit-b0', metadata={'help': 'Path to pretrained model or mode... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
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='nvidia/mit-b0', metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
137 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/question-answering/run_seq2seq_qa.py | run_seq2seq_qa.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.
"""
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 dataclasses import dataclass, field
from typing import Optional
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 dataclasses import dataclass, field
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
138 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/question-answering/run_seq2seq_qa.py | run_seq2seq_qa.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
139 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py | run_speech_recognition_ctc.DataCollatorCTCWithPadding | from transformers import AutoConfig, AutoFeatureExtractor, AutoModelForCTC, AutoProcessor, AutoTokenizer, HfArgumentParser, Trainer, TrainingArguments, Wav2Vec2Processor, set_seed
import torch
from typing import Optional, Union
from dataclasses import dataclass, field
@dataclass
class DataCollatorCTCWithPadding:
"... | """Data collator that will dynamically pad the inputs received.
Args:
processor (:class:`~transformers.AutoProcessor`)
The processor used for processing the data.
padding (:obj:`bool`, :obj:`str` or :class:`~transformers.tokenization_utils_base.PaddingStrategy`, `optional`, defaults to :obj:`True`):
... | class DataCollatorCTCWithPadding:
"""
Data collator that will dynamically pad the inputs received.
Args:
processor (:class:`~transformers.AutoProcessor`)
The processor used for processing the data.
padding (:obj:`bool`, :obj:`str` or :class:`~transformers.tokenization_utils_base.... | from transformers import AutoConfig, AutoFeatureExtractor, AutoModelForCTC, AutoProcessor, AutoTokenizer, HfArgumentParser, Trainer, TrainingArguments, Wav2Vec2Processor, set_seed
import torch
from typing import Optional, Union
from dataclasses import dataclass, field | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
140 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py | run_speech_recognition_ctc.ModelArguments | from typing import Optional, Union
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from ... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional, Union
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
tokenizer_name_or_path: Optional[str] = field(default=None,... | from typing import Optional, Union
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
141 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py | run_speech_recognition_ctc_adapter.DataCollatorCTCWithPadding | from transformers import AutoConfig, AutoFeatureExtractor, AutoModelForCTC, AutoProcessor, AutoTokenizer, HfArgumentParser, Trainer, TrainingArguments, Wav2Vec2Processor, set_seed
import torch
from typing import Optional, Union
from dataclasses import dataclass, field
@dataclass
class DataCollatorCTCWithPadding:
"... | """Data collator that will dynamically pad the inputs received.
Args:
processor (:class:`~transformers.AutoProcessor`)
The processor used for processing the data.
padding (:obj:`bool`, :obj:`str` or :class:`~transformers.tokenization_utils_base.PaddingStrategy`, `optional`, defaults to :obj:`True`):
... | class DataCollatorCTCWithPadding:
"""
Data collator that will dynamically pad the inputs received.
Args:
processor (:class:`~transformers.AutoProcessor`)
The processor used for processing the data.
padding (:obj:`bool`, :obj:`str` or :class:`~transformers.tokenization_utils_base.... | from transformers import AutoConfig, AutoFeatureExtractor, AutoModelForCTC, AutoProcessor, AutoTokenizer, HfArgumentParser, Trainer, TrainingArguments, Wav2Vec2Processor, set_seed
import torch
from typing import Optional, Union
from dataclasses import dataclass, field | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
142 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py | run_speech_recognition_ctc_adapter.ModelArguments | from dataclasses import dataclass, field
from typing import Optional, Union
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from ... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from dataclasses import dataclass, field
from typing import Optional, Union
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
tokenizer_name_or_path: Optional[str] = field(default=None,... | from dataclasses import dataclass, field
from typing import Optional, Union | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
143 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/speech-recognition/run_speech_recognition_seq2seq.py | run_speech_recognition_seq2seq.DataCollatorSpeechSeq2SeqWithPadding | import torch
from dataclasses import dataclass, field
from typing import Any, Optional, Union
@dataclass
class DataCollatorSpeechSeq2SeqWithPadding:
"""
Data collator that will dynamically pad the inputs received.
Args:
processor ([`WhisperProcessor`])
The processor used for processing ... | """Data collator that will dynamically pad the inputs received.
Args:
processor ([`WhisperProcessor`])
The processor used for processing the data.
decoder_start_token_id (`int`)
The begin-of-sentence of the decoder.
forward_attention_mask (`bool`)
Whether to return attention_mask.
R... | class DataCollatorSpeechSeq2SeqWithPadding:
"""
Data collator that will dynamically pad the inputs received.
Args:
processor ([`WhisperProcessor`])
The processor used for processing the data.
decoder_start_token_id (`int`)
The begin-of-sentence of the decoder.
... | import torch
from dataclasses import dataclass, field
from typing import Any, Optional, Union | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
144 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/speech-recognition/run_speech_recognition_seq2seq.py | run_speech_recognition_seq2seq.DataTrainingArguments | from typing import Any, Optional, Union
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: str = field(default=None, metadata={'help': 'The name of the dataset to... | """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):
"""
from typing import Any, Optional, Union
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: str = field(default=None, metadata={'help': 'The name of the dataset to use (via the datasets library).'})
dataset_config_name: Optional[str] = field(default=No... | from typing import Any, Optional, Union
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
145 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/speech-recognition/run_speech_recognition_seq2seq.py | run_speech_recognition_seq2seq.ModelArguments | from typing import Any, Optional, Union
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier ... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Any, Optional, Union
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from typing import Any, Optional, Union
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
146 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/question-answering/run_squad_trainer.py | run_squad_trainer.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 from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
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 from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from dataclasses import dataclass, field
from typing import Optional | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
147 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/summarization/run_summarization.py | run_summarization.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.
"""
lang: Optional[str] = field(default=None, metadata={'help': 'Language id for summarization.'})
... | """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 typing import Optional
class DataTrainingArguments: | class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
lang: Optional[str] = field(default=None, metadata={'help': 'Language id for summarization.'})
dataset_name: Optional[str] = field(default=None, metadata={'help': 'The name o... | from dataclasses import dataclass, field
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
148 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/summarization/run_summarization.py | run_summarization.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 from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
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 from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from dataclasses import dataclass, field
from typing import Optional | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
149 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/multiple-choice/run_swag.py | run_swag.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.
"""
train_file: Optional[str] = field(default=None, metadata={'help': 'The input training data file (... | """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 typing import Optional
class DataTrainingArguments: | class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
train_file: Optional[str] = field(default=None, metadata={'help': 'The input training data file (a text file).'})
validation_file: Optional[str] = field(default=None, metadat... | from dataclasses import dataclass, field
from typing import Optional | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
150 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/run_swag.py | run_swag.InputFeatures | class InputFeatures:
def __init__(self, example_id, choices_features, label):
self.example_id = example_id
self.choices_features = [{'input_ids': input_ids, 'input_mask': input_mask, 'segment_ids': segment_ids} for _, input_ids, input_mask, segment_ids in choices_features]
self.label = labe... | """Implement class InputFeatures.
Required methods (implement on the class; order is not specified):
- `__init__(self, example_id, choices_features, label)`"""
class InputFeatures: |
def __init__(self, example_id, choices_features, label):
self.example_id = example_id
self.choices_features = [{'input_ids': input_ids, 'input_mask': input_mask, 'segment_ids': segment_ids} for _, input_ids, input_mask, segment_ids in choices_features]
self.label = label
| 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | |||
151 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/multiple-choice/run_swag.py | run_swag.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
class ModelArguments: | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
152 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/run_swag.py | run_swag.SwagExample | class SwagExample:
"""A single training/test example for the SWAG dataset."""
def __init__(self, swag_id, context_sentence, start_ending, ending_0, ending_1, ending_2, ending_3, label=None):
self.swag_id = swag_id
self.context_sentence = context_sentence
self.start_ending = start_ending... | """A single training/test example for the SWAG dataset.
Required methods (implement on the class; order is not specified):
- `__init__(self, swag_id, context_sentence, start_ending, ending_0, ending_1, ending_2, ending_3, label=None)`
- `__str__(self)`
- `__repr__(self)`"""
class SwagExample: | """A single training/test example for the SWAG dataset."""
def __init__(self, swag_id, context_sentence, start_ending, ending_0, ending_1, ending_2, ending_3, label=None):
self.swag_id = swag_id
self.context_sentence = context_sentence
self.start_ending = start_ending
self.endin... | 3 | 1 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | |||
153 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/translation/run_translation.py | run_translation.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.
"""
source_lang: str = field(default=None, metadata={'help': 'Source language id for translation.'})
... | """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.
"""
source_lang: str = field(default=None, metadata={'help': 'Source language id for translation.'})
target_lang: str = field(default=None, metadata={'help': 'Target language id ... | from typing import Optional
from dataclasses import dataclass, field | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
154 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/translation/run_translation.py | run_translation.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 from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from hugging... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
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 from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from dataclasses import dataclass, field
from typing import Optional | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
155 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/speech-pretraining/run_wav2vec2_pretraining_no_trainer.py | run_wav2vec2_pretraining_no_trainer.DataCollatorForWav2Vec2Pretraining | import torch
from typing import Optional, Union
from transformers import SchedulerType, Wav2Vec2Config, Wav2Vec2FeatureExtractor, Wav2Vec2ForPreTraining, get_scheduler, is_wandb_available, set_seed
from dataclasses import dataclass
from transformers.models.wav2vec2.modeling_wav2vec2 import _compute_mask_indices, _sampl... | """Data collator that will dynamically pad the inputs received and prepare masked indices
for self-supervised pretraining.
Args:
model (:class:`~transformers.Wav2Vec2ForPreTraining`):
The Wav2Vec2 model used for pretraining. The data collator needs to have access
to config and ``_get_feat_extract_o... | class DataCollatorForWav2Vec2Pretraining:
"""
Data collator that will dynamically pad the inputs received and prepare masked indices
for self-supervised pretraining.
Args:
model (:class:`~transformers.Wav2Vec2ForPreTraining`):
The Wav2Vec2 model used for pretraining. The data collat... | import torch
from typing import Optional, Union
from transformers import SchedulerType, Wav2Vec2Config, Wav2Vec2FeatureExtractor, Wav2Vec2ForPreTraining, get_scheduler, is_wandb_available, set_seed
from dataclasses import dataclass
from transformers.models.wav2vec2.modeling_wav2vec2 import _compute_mask_indices, _sampl... | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
156 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/text-classification/run_xnli.py | run_xnli.ModelArguments | from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(default=None, metadata={'help': 'Path to pretrained model or model identifie... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from typing import Optional
from dataclasses import dataclass, field
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=None, metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
language: str = field(default=None, metadata=... | from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
157 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/seq2seq/finetune_trainer.py | seq2seq.finetune_trainer.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.
"""
data_dir: str = field(metadata={'help': 'The input data dir. Should contain the .tsv files (or ot... | """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):
"""
from dataclasses import dataclass, field
from typing import Optional
class DataTrainingArguments: | class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
data_dir: str = field(metadata={'help': 'The input data dir. Should contain the .tsv files (or other data files) for the task.'})
task: Optional[str] = field(default='summari... | from dataclasses import dataclass, field
from typing import Optional | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
158 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/seq2seq/finetune_trainer.py | seq2seq.finetune_trainer.ModelArguments | from utils import Seq2SeqDataCollator, Seq2SeqDataset, assert_all_frozen, build_compute_metrics_fn, check_output_dir, freeze_embeds, freeze_params, lmap, save_json, use_task_specific_params, write_txt_file
from typing import Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
"""
... | """Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
Required methods (implement on the class; order is not specified):
"""
from utils import Seq2SeqDataCollator, Seq2SeqDataset, assert_all_frozen, build_compute_metrics_fn, check_output_dir, freeze_embeds, freeze_params, lmap, save_j... | class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'})
config_name: Optional[str] = field(default=None, metadata={... | from utils import Seq2SeqDataCollator, Seq2SeqDataset, assert_all_frozen, build_compute_metrics_fn, check_output_dir, freeze_embeds, freeze_params, lmap, save_json, use_task_specific_params, write_txt_file
from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
159 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/seq2seq/seq2seq_trainer.py | seq2seq.seq2seq_trainer.Seq2SeqTrainer | from transformers import PreTrainedModel, Trainer, logging
from transformers.training_args import ParallelMode
from transformers.utils import is_torch_xla_available
from transformers.optimization import Adafactor, get_constant_schedule, get_constant_schedule_with_warmup, get_cosine_schedule_with_warmup, get_cosine_with... | """Implement class Seq2SeqTrainer.
Required methods (implement on the class; order is not specified):
- `__init__(self, config=None, data_args=None, *args, **kwargs)`
- `create_optimizer_and_scheduler(self, num_training_steps: int)`: Setup the optimizer and the learning rate scheduler.
- `_get_lr_scheduler(self, num_t... |
def __init__(self, config=None, data_args=None, *args, **kwargs):
super().__init__(*args, **kwargs)
if config is None:
assert isinstance(self.model, PreTrainedModel), f'If no `config` is passed the model to be trained has to be of type `PreTrainedModel`, but is {self.model.__class__}'
... | from transformers import PreTrainedModel, Trainer, logging
from transformers.training_args import ParallelMode
from transformers.utils import is_torch_xla_available
from transformers.optimization import Adafactor, get_constant_schedule, get_constant_schedule_with_warmup, get_cosine_schedule_with_warmup, get_cosine_with... | 8 | 4 | 4 | 0.25 | true | mrahman2025/OpenClassGen | [] | ||
160 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/seq2seq/seq2seq_training_args.py | seq2seq.seq2seq_training_args.Seq2SeqTrainingArguments | from seq2seq_trainer import arg_to_scheduler
from transformers import TrainingArguments
from typing import Optional
from dataclasses import dataclass, field
@dataclass
class Seq2SeqTrainingArguments(TrainingArguments):
"""
Parameters:
label_smoothing (:obj:`float`, `optional`, defaults to 0):
... | """Parameters:
label_smoothing (:obj:`float`, `optional`, defaults to 0):
The label smoothing epsilon to apply (if not zero).
sortish_sampler (:obj:`bool`, `optional`, defaults to :obj:`False`):
Whether to SortishSampler or not. It sorts the inputs according to lengths in-order to minimizing the... | class Seq2SeqTrainingArguments(TrainingArguments):
"""
Parameters:
label_smoothing (:obj:`float`, `optional`, defaults to 0):
The label smoothing epsilon to apply (if not zero).
sortish_sampler (:obj:`bool`, `optional`, defaults to :obj:`False`):
Whether to SortishSampler... | from seq2seq_trainer import arg_to_scheduler
from transformers import TrainingArguments
from typing import Optional
from dataclasses import dataclass, field | 0 | 0 | 0 | 0 | true | mrahman2025/OpenClassGen | [] | ||
161 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/seq2seq/utils.py | seq2seq.utils.AbstractSeq2SeqDataset | from transformers.utils import cached_property
import os
from pathlib import Path
from torch.utils.data import Dataset, Sampler
import numpy as np
from transformers import BartTokenizer, EvalPrediction, PreTrainedTokenizer, T5Tokenizer
class AbstractSeq2SeqDataset(Dataset):
def __init__(self, tokenizer, data_dir,... | """Implement class AbstractSeq2SeqDataset.
Required methods (implement on the class; order is not specified):
- `__init__(self, tokenizer, data_dir, max_source_length, max_target_length, type_path='train', n_obs=None, prefix='', **dataset_kwargs)`
- `__len__(self)`
- `get_char_lens(data_file)`
- `tgt_lens(self)`: Leng... |
def __init__(self, tokenizer, data_dir, max_source_length, max_target_length, type_path='train', n_obs=None, prefix='', **dataset_kwargs):
super().__init__()
self.src_file = Path(data_dir).joinpath(type_path + '.source')
self.tgt_file = Path(data_dir).joinpath(type_path + '.target')
... | from transformers.utils import cached_property
import os
from pathlib import Path
from torch.utils.data import Dataset, Sampler
import numpy as np
from transformers import BartTokenizer, EvalPrediction, PreTrainedTokenizer, T5Tokenizer | 8 | 3 | 5 | 0.125 | true | mrahman2025/OpenClassGen | [] | ||
162 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/seq2seq/utils.py | seq2seq.utils.DistributedSortishSampler | import torch
import numpy as np
from torch.utils.data import Dataset, Sampler
import torch.distributed as dist
from collections.abc import Iterable
from transformers.utils import cached_property
import math
class DistributedSortishSampler(Sampler):
"""Copied from torch DistributedSampler"""
def __init__(self,... | """Copied from torch DistributedSampler
Required methods (implement on the class; order is not specified):
- `__init__(self, dataset, batch_size, num_replicas=None, rank=None, add_extra_examples=True, shuffle=True)`
- `__iter__(self)`
- `available_indices(self)`
- `__len__(self)`
- `set_epoch(self, epoch)`"""
import t... | """Copied from torch DistributedSampler"""
def __init__(self, dataset, batch_size, num_replicas=None, rank=None, add_extra_examples=True, shuffle=True):
if num_replicas is None:
if not dist.is_available():
raise RuntimeError('Requires distributed package to be available')
... | import torch
import numpy as np
from torch.utils.data import Dataset, Sampler
import torch.distributed as dist
from collections.abc import Iterable
from transformers.utils import cached_property
import math | 5 | 0 | 5 | 0 | true | mrahman2025/OpenClassGen | [] | ||
163 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/seq2seq/utils.py | seq2seq.utils.LegacySeq2SeqDataset | import torch.distributed as dist
import torch
import linecache
class LegacySeq2SeqDataset(AbstractSeq2SeqDataset):
def __getitem__(self, index) -> dict[str, torch.Tensor]:
"""Call tokenizer on src and tgt_lines"""
index = index + 1
source_line = self.prefix + linecache.getline(str(self.src... | """Implement class LegacySeq2SeqDataset.
Required methods (implement on the class; order is not specified):
- `__getitem__(self, index)`: Call tokenizer on src and tgt_lines
- `encode_line(self, tokenizer, line, max_length, pad_to_max_length=True, return_tensors='pt')`: Only used by LegacyDataset
- `collate_fn(self, b... |
def __getitem__(self, index) -> dict[str, torch.Tensor]:
"""Call tokenizer on src and tgt_lines"""
index = index + 1
source_line = self.prefix + linecache.getline(str(self.src_file), index).rstrip('\n')
tgt_line = linecache.getline(str(self.tgt_file), index).rstrip('\n')
ass... | import torch.distributed as dist
import torch
import linecache | 3 | 1 | 2 | 0.666667 | true | mrahman2025/OpenClassGen | [] | ||
164 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/seq2seq/utils.py | seq2seq.utils.Seq2SeqDataCollator | import torch.distributed as dist
import torch
from transformers import BartTokenizer, EvalPrediction, PreTrainedTokenizer, T5Tokenizer
from transformers.models.bart.modeling_bart import shift_tokens_right
class Seq2SeqDataCollator:
def __init__(self, tokenizer, data_args, decoder_start_token_id, tpu_num_cores=Non... | """Implement class Seq2SeqDataCollator.
Required methods (implement on the class; order is not specified):
- `__init__(self, tokenizer, data_args, decoder_start_token_id, tpu_num_cores=None)`
- `__call__(self, batch)`
- `_shift_right_t5(self, input_ids)`
- `_encode(self, batch)`"""
import torch.distributed as dist
imp... |
def __init__(self, tokenizer, data_args, decoder_start_token_id, tpu_num_cores=None):
self.tokenizer = tokenizer
self.pad_token_id = tokenizer.pad_token_id
self.decoder_start_token_id = decoder_start_token_id
assert self.pad_token_id is not None, f'pad_token_id is not defined for ({... | import torch.distributed as dist
import torch
from transformers import BartTokenizer, EvalPrediction, PreTrainedTokenizer, T5Tokenizer
from transformers.models.bart.modeling_bart import shift_tokens_right | 4 | 2 | 3 | 0 | true | mrahman2025/OpenClassGen | [] | ||
165 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/seq2seq/utils.py | seq2seq.utils.Seq2SeqDataset | import torch.distributed as dist
import torch
import linecache
class Seq2SeqDataset(AbstractSeq2SeqDataset):
"""A dataset that calls prepare_seq2seq_batch."""
def __getitem__(self, index) -> dict[str, str]:
index = index + 1
source_line = self.prefix + linecache.getline(str(self.src_file), ind... | """A dataset that calls prepare_seq2seq_batch.
Required methods (implement on the class; order is not specified):
- `__getitem__(self, index)`
- `collate_fn(self, batch)`: Call prepare_seq2seq_batch."""
import torch.distributed as dist
import torch
import linecache
class Seq2SeqDataset: | """A dataset that calls prepare_seq2seq_batch."""
def __getitem__(self, index) -> dict[str, str]:
index = index + 1
source_line = self.prefix + linecache.getline(str(self.src_file), index).rstrip('\n')
tgt_line = linecache.getline(str(self.tgt_file), index).rstrip('\n')
assert s... | import torch.distributed as dist
import torch
import linecache | 2 | 0 | 2 | 0.5 | true | mrahman2025/OpenClassGen | [] | ||
166 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/seq2seq/utils.py | seq2seq.utils.SortishSampler | from torch.utils.data import Dataset, Sampler
class SortishSampler(Sampler):
"""Go through the text data by order of src length with a bit of randomness. From fastai repo."""
def __init__(self, data, batch_size, shuffle=True):
self.data, self.bs, self.shuffle = (data, batch_size, shuffle)
def __l... | """Go through the text data by order of src length with a bit of randomness. From fastai repo.
Required methods (implement on the class; order is not specified):
- `__init__(self, data, batch_size, shuffle=True)`
- `__len__(self)`
- `__iter__(self)`"""
from torch.utils.data import Dataset, Sampler
class SortishSample... | """Go through the text data by order of src length with a bit of randomness. From fastai repo."""
def __init__(self, data, batch_size, shuffle=True):
self.data, self.bs, self.shuffle = (data, batch_size, shuffle)
def __len__(self) -> int:
return len(self.data)
def __iter__(self):
... | from torch.utils.data import Dataset, Sampler | 3 | 0 | 3 | 0 | true | mrahman2025/OpenClassGen | [] | ||
167 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/setup.py | setup.DepsTableUpdateCommand | from setuptools import Command, find_packages, setup
class DepsTableUpdateCommand(Command):
"""
A custom distutils command that updates the dependency table.
usage: python setup.py deps_table_update
"""
description = 'build runtime dependency table'
user_options = [('dep-table-update', None, 'u... | """A custom distutils command that updates the dependency table.
usage: python setup.py deps_table_update
Required methods (implement on the class; order is not specified):
- `initialize_options(self)`
- `finalize_options(self)`
- `run(self)`"""
from setuptools import Command, find_packages, setup
class DepsTableUpda... | """
A custom distutils command that updates the dependency table.
usage: python setup.py deps_table_update
"""
description = 'build runtime dependency table'
user_options = [('dep-table-update', None, 'updates src/transformers/dependency_versions_table.py')]
def initialize_options(self):
... | from setuptools import Command, find_packages, setup | 3 | 0 | 3 | 0 | true | mrahman2025/OpenClassGen | [] | ||
168 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/token-classification/tasks.py | tasks.Chunk | class Chunk(NER):
def __init__(self):
super().__init__(label_idx=-2)
def get_labels(self, path: str) -> list[str]:
if path:
with open(path) as f:
labels = f.read().splitlines()
if 'O' not in labels:
labels = ['O'] + labels
ret... | """Implement class Chunk.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `get_labels(self, path: str)`"""
class Chunk: |
def __init__(self):
super().__init__(label_idx=-2)
def get_labels(self, path: str) -> list[str]:
if path:
with open(path) as f:
labels = f.read().splitlines()
if 'O' not in labels:
labels = ['O'] + labels
return labels
... | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | |||
169 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/token-classification/tasks.py | tasks.NER | import os
from typing import TextIO, Union
from utils_ner import InputExample, Split, TokenClassificationTask
class NER(TokenClassificationTask):
def __init__(self, label_idx=-1):
self.label_idx = label_idx
def read_examples_from_file(self, data_dir, mode: Union[Split, str]) -> list[InputExample]:
... | """Implement class NER.
Required methods (implement on the class; order is not specified):
- `__init__(self, label_idx=-1)`
- `read_examples_from_file(self, data_dir, mode: Union[Split, str])`
- `write_predictions_to_file(self, writer: TextIO, test_input_reader: TextIO, preds_list: list)`
- `get_labels(self, path: str... |
def __init__(self, label_idx=-1):
self.label_idx = label_idx
def read_examples_from_file(self, data_dir, mode: Union[Split, str]) -> list[InputExample]:
if isinstance(mode, Split):
mode = mode.value
file_path = os.path.join(data_dir, f'{mode}.txt')
guid_index = 1
... | import os
from typing import TextIO, Union
from utils_ner import InputExample, Split, TokenClassificationTask | 4 | 0 | 4 | 0 | true | mrahman2025/OpenClassGen | [] | ||
170 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/legacy/token-classification/tasks.py | tasks.POS | from conllu import parse_incr
from typing import TextIO, Union
import os
from utils_ner import InputExample, Split, TokenClassificationTask
class POS(TokenClassificationTask):
def read_examples_from_file(self, data_dir, mode: Union[Split, str]) -> list[InputExample]:
if isinstance(mode, Split):
... | """Implement class POS.
Required methods (implement on the class; order is not specified):
- `read_examples_from_file(self, data_dir, mode: Union[Split, str])`
- `write_predictions_to_file(self, writer: TextIO, test_input_reader: TextIO, preds_list: list)`
- `get_labels(self, path: str)`"""
from conllu import parse_in... |
def read_examples_from_file(self, data_dir, mode: Union[Split, str]) -> list[InputExample]:
if isinstance(mode, Split):
mode = mode.value
file_path = os.path.join(data_dir, f'{mode}.txt')
guid_index = 1
examples = []
with open(file_path, encoding='utf-8') as f:
... | from conllu import parse_incr
from typing import TextIO, Union
import os
from utils_ner import InputExample, Split, TokenClassificationTask | 3 | 0 | 3 | 0 | true | mrahman2025/OpenClassGen | [] | ||
171 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/question-answering/trainer_qa.py | trainer_qa.QuestionAnsweringTrainer | import math
import time
from transformers.trainer_utils import PredictionOutput, speed_metrics
from transformers import Trainer, is_torch_xla_available
class QuestionAnsweringTrainer(Trainer):
def __init__(self, *args, eval_examples=None, post_process_function=None, **kwargs):
super().__init__(*args, **kw... | """Implement class QuestionAnsweringTrainer.
Required methods (implement on the class; order is not specified):
- `__init__(self, *args, eval_examples=None, post_process_function=None, **kwargs)`
- `evaluate(self, eval_dataset=None, eval_examples=None, ignore_keys=None, metric_key_prefix: str='eval')`
- `predict(self,... |
def __init__(self, *args, eval_examples=None, post_process_function=None, **kwargs):
super().__init__(*args, **kwargs)
self.eval_examples = eval_examples
self.post_process_function = post_process_function
def evaluate(self, eval_dataset=None, eval_examples=None, ignore_keys=None, metri... | import math
import time
from transformers.trainer_utils import PredictionOutput, speed_metrics
from transformers import Trainer, is_torch_xla_available | 3 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
172 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/examples/pytorch/question-answering/trainer_seq2seq_qa.py | trainer_seq2seq_qa.QuestionAnsweringSeq2SeqTrainer | from typing import Optional
from torch.utils.data import Dataset
from transformers.trainer_utils import PredictionOutput, speed_metrics
import math
import time
from transformers import Seq2SeqTrainer, is_torch_xla_available
class QuestionAnsweringSeq2SeqTrainer(Seq2SeqTrainer):
def __init__(self, *args, eval_exam... | """Implement class QuestionAnsweringSeq2SeqTrainer.
Required methods (implement on the class; order is not specified):
- `__init__(self, *args, eval_examples=None, post_process_function=None, **kwargs)`
- `evaluate(self, eval_dataset: Optional[Dataset]=None, eval_examples=None, ignore_keys: Optional[list[str]]=None, m... |
def __init__(self, *args, eval_examples=None, post_process_function=None, **kwargs):
super().__init__(*args, **kwargs)
self.eval_examples = eval_examples
self.post_process_function = post_process_function
def evaluate(self, eval_dataset: Optional[Dataset]=None, eval_examples=None, igno... | from typing import Optional
from torch.utils.data import Dataset
from transformers.trainer_utils import PredictionOutput, speed_metrics
import math
import time
from transformers import Seq2SeqTrainer, is_torch_xla_available | 3 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
173 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.AccurateGELUActivation | import math
import torch
from torch import Tensor, nn
class AccurateGELUActivation(nn.Module):
"""
Applies GELU approximation that is faster than default and more accurate than QuickGELU. See:
https://github.com/hendrycks/GELUs
Implemented along with MEGA (Moving Average Equipped Gated Attention)
... | """Applies GELU approximation that is faster than default and more accurate than QuickGELU. See:
https://github.com/hendrycks/GELUs
Implemented along with MEGA (Moving Average Equipped Gated Attention)
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `forward(self, input: Tensor... | """
Applies GELU approximation that is faster than default and more accurate than QuickGELU. See:
https://github.com/hendrycks/GELUs
Implemented along with MEGA (Moving Average Equipped Gated Attention)
"""
def __init__(self):
super().__init__()
self.precomputed_constant = math... | import math
import torch
from torch import Tensor, nn | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
174 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.ClassInstantier | from collections import OrderedDict
class ClassInstantier(OrderedDict):
def __getitem__(self, key):
content = super().__getitem__(key)
cls, kwargs = content if isinstance(content, tuple) else (content, {})
return cls(**kwargs) | """Implement class ClassInstantier.
Required methods (implement on the class; order is not specified):
- `__getitem__(self, key)`"""
from collections import OrderedDict
class ClassInstantier: |
def __getitem__(self, key):
content = super().__getitem__(key)
cls, kwargs = content if isinstance(content, tuple) else (content, {})
return cls(**kwargs)
| from collections import OrderedDict | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
175 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.ClippedGELUActivation | import torch
from torch import Tensor, nn
class ClippedGELUActivation(nn.Module):
"""
Clip the range of possible GeLU outputs between [min, max]. This is especially useful for quantization purpose, as
it allows mapping negatives values in the GeLU spectrum. For more information on this trick, please refer ... | """Clip the range of possible GeLU outputs between [min, max]. This is especially useful for quantization purpose, as
it allows mapping negatives values in the GeLU spectrum. For more information on this trick, please refer to
https://huggingface.co/papers/2004.09602.
Gaussian Error Linear Unit. Original Implementatio... | """
Clip the range of possible GeLU outputs between [min, max]. This is especially useful for quantization purpose, as
it allows mapping negatives values in the GeLU spectrum. For more information on this trick, please refer to
https://huggingface.co/papers/2004.09602.
Gaussian Error Linear Unit. O... | import torch
from torch import Tensor, nn | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
176 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.FastGELUActivation | import torch
from .integrations.hub_kernels import use_kernel_forward_from_hub
from torch import Tensor, nn
@use_kernel_forward_from_hub('FastGELU')
class FastGELUActivation(nn.Module):
"""
Applies GELU approximation that is slower than QuickGELU but more accurate. See: https://github.com/hendrycks/GELUs
"... | """Applies GELU approximation that is slower than QuickGELU but more accurate. See: https://github.com/hendrycks/GELUs
Required methods (implement on the class; order is not specified):
- `forward(self, input: Tensor)`"""
import torch
from .integrations.hub_kernels import use_kernel_forward_from_hub
from torch import ... | class FastGELUActivation(nn.Module):
"""
Applies GELU approximation that is slower than QuickGELU but more accurate. See: https://github.com/hendrycks/GELUs
"""
def forward(self, input: Tensor) -> Tensor:
return 0.5 * input * (1.0 + torch.tanh(input * 0.7978845608 * (1.0 + 0.044715 * input * in... | import torch
from .integrations.hub_kernels import use_kernel_forward_from_hub
from torch import Tensor, nn | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
177 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.GELUActivation | import torch
from torch import Tensor, nn
import math
class GELUActivation(nn.Module):
"""
Original Implementation of the GELU activation function in Google BERT repo when initially created. For
information: OpenAI GPT's GELU is slightly different (and gives slightly different results): 0.5 * x * (1 +
... | """Original Implementation of the GELU activation function in Google BERT repo when initially created. For
information: OpenAI GPT's GELU is slightly different (and gives slightly different results): 0.5 * x * (1 +
torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))) This is now written in C in nn.fun... | """
Original Implementation of the GELU activation function in Google BERT repo when initially created. For
information: OpenAI GPT's GELU is slightly different (and gives slightly different results): 0.5 * x * (1 +
torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))) This is now writt... | import torch
from torch import Tensor, nn
import math | 3 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
178 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.LaplaceActivation | import torch
from torch import Tensor, nn
import math
class LaplaceActivation(nn.Module):
"""
Applies elementwise activation based on Laplace function, introduced in MEGA as an attention activation. See
https://huggingface.co/papers/2209.10655
Inspired by squared relu, but with bounded range and gradi... | """Applies elementwise activation based on Laplace function, introduced in MEGA as an attention activation. See
https://huggingface.co/papers/2209.10655
Inspired by squared relu, but with bounded range and gradient for better stability
Required methods (implement on the class; order is not specified):
- `forward(self... | """
Applies elementwise activation based on Laplace function, introduced in MEGA as an attention activation. See
https://huggingface.co/papers/2209.10655
Inspired by squared relu, but with bounded range and gradient for better stability
"""
def forward(self, input, mu=0.707107, sigma=0.282095)... | import torch
from torch import Tensor, nn
import math | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
179 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.LinearActivation | from torch import Tensor, nn
class LinearActivation(nn.Module):
"""
Applies the linear activation function, i.e. forwarding input directly to output.
"""
def forward(self, input: Tensor) -> Tensor:
return input | """Applies the linear activation function, i.e. forwarding input directly to output.
Required methods (implement on the class; order is not specified):
- `forward(self, input: Tensor)`"""
from torch import Tensor, nn
class LinearActivation: | """
Applies the linear activation function, i.e. forwarding input directly to output.
"""
def forward(self, input: Tensor) -> Tensor:
return input
| from torch import Tensor, nn | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
180 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.MishActivation | from torch import Tensor, nn
import torch
class MishActivation(nn.Module):
"""
See Mish: A Self-Regularized Non-Monotonic Activation Function (Misra., https://huggingface.co/papers/1908.08681). Also
visit the official repository for the paper: https://github.com/digantamisra98/Mish
"""
def __init_... | """See Mish: A Self-Regularized Non-Monotonic Activation Function (Misra., https://huggingface.co/papers/1908.08681). Also
visit the official repository for the paper: https://github.com/digantamisra98/Mish
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `_mish_python(self, inpu... | """
See Mish: A Self-Regularized Non-Monotonic Activation Function (Misra., https://huggingface.co/papers/1908.08681). Also
visit the official repository for the paper: https://github.com/digantamisra98/Mish
"""
def __init__(self):
super().__init__()
self.act = nn.functional.mish
... | from torch import Tensor, nn
import torch | 3 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
181 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.NewGELUActivation | from .integrations.hub_kernels import use_kernel_forward_from_hub
import torch
from torch import Tensor, nn
import math
@use_kernel_forward_from_hub('NewGELU')
class NewGELUActivation(nn.Module):
"""
Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT). Also se... | """Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT). Also see
the Gaussian Error Linear Units paper: https://huggingface.co/papers/1606.08415
Required methods (implement on the class; order is not specified):
- `forward(self, input: Tensor)`"""
from .integrations.h... | class NewGELUActivation(nn.Module):
"""
Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT). Also see
the Gaussian Error Linear Units paper: https://huggingface.co/papers/1606.08415
"""
def forward(self, input: Tensor) -> Tensor:
return 0.5... | from .integrations.hub_kernels import use_kernel_forward_from_hub
import torch
from torch import Tensor, nn
import math | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
182 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.PytorchGELUTanh | from torch import Tensor, nn
class PytorchGELUTanh(nn.Module):
"""
A fast C implementation of the tanh approximation of the GeLU activation function. See
https://huggingface.co/papers/1606.08415.
This implementation is equivalent to NewGELU and FastGELU but much faster. However, it is not an exact num... | """A fast C implementation of the tanh approximation of the GeLU activation function. See
https://huggingface.co/papers/1606.08415.
This implementation is equivalent to NewGELU and FastGELU but much faster. However, it is not an exact numerical
match due to rounding errors.
Required methods (implement on the class; o... | """
A fast C implementation of the tanh approximation of the GeLU activation function. See
https://huggingface.co/papers/1606.08415.
This implementation is equivalent to NewGELU and FastGELU but much faster. However, it is not an exact numerical
match due to rounding errors.
"""
def forwar... | from torch import Tensor, nn | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
183 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.QuickGELUActivation | from .integrations.hub_kernels import use_kernel_forward_from_hub
from torch import Tensor, nn
import torch
@use_kernel_forward_from_hub('QuickGELU')
class QuickGELUActivation(nn.Module):
"""
Applies GELU approximation that is fast but somewhat inaccurate. See: https://github.com/hendrycks/GELUs
"""
d... | """Applies GELU approximation that is fast but somewhat inaccurate. See: https://github.com/hendrycks/GELUs
Required methods (implement on the class; order is not specified):
- `forward(self, input: Tensor)`"""
from .integrations.hub_kernels import use_kernel_forward_from_hub
from torch import Tensor, nn
import torch
... | class QuickGELUActivation(nn.Module):
"""
Applies GELU approximation that is fast but somewhat inaccurate. See: https://github.com/hendrycks/GELUs
"""
def forward(self, input: Tensor) -> Tensor:
return input * torch.sigmoid(1.702 * input)
| from .integrations.hub_kernels import use_kernel_forward_from_hub
from torch import Tensor, nn
import torch | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
184 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/activations.py | transformers.activations.ReLUSquaredActivation | import torch
from torch import Tensor, nn
class ReLUSquaredActivation(nn.Module):
"""
Applies the relu^2 activation introduced in https://huggingface.co/papers/2109.08668v2
"""
def forward(self, input):
relu_applied = nn.functional.relu(input)
squared = torch.square(relu_applied)
... | """Applies the relu^2 activation introduced in https://huggingface.co/papers/2109.08668v2
Required methods (implement on the class; order is not specified):
- `forward(self, input)`"""
import torch
from torch import Tensor, nn
class ReLUSquaredActivation: | """
Applies the relu^2 activation introduced in https://huggingface.co/papers/2109.08668v2
"""
def forward(self, input):
relu_applied = nn.functional.relu(input)
squared = torch.square(relu_applied)
return squared
| import torch
from torch import Tensor, nn | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
185 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.Cache | from typing import Any, Optional
import torch
class Cache:
"""
A `Cache` is mostly a list of `CacheLayerMixin` objects, one per model layer. It serves as a container for
the Cache of each layer.
Args:
layers (`Optional`, *optional*):
A list of pre-created `CacheLayerMixin`. If omit... | """A `Cache` is mostly a list of `CacheLayerMixin` objects, one per model layer. It serves as a container for
the Cache of each layer.
Args:
layers (`Optional`, *optional*):
A list of pre-created `CacheLayerMixin`. If omitted (`None`), then `layer_class_to_replicate` will
be used.
layer_class_t... | """
A `Cache` is mostly a list of `CacheLayerMixin` objects, one per model layer. It serves as a container for
the Cache of each layer.
Args:
layers (`Optional`, *optional*):
A list of pre-created `CacheLayerMixin`. If omitted (`None`), then `layer_class_to_replicate` will
... | from typing import Any, Optional
import torch | 22 | 2 | 21 | 0.909091 | true | mrahman2025/OpenClassGen | [] | ||
186 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.DynamicCache | import torch
from collections.abc import Iterable
from typing import Any, Optional
from .configuration_utils import PretrainedConfig
class DynamicCache(Cache):
"""
A cache that grows dynamically as more tokens are generated. This is the default for generative models.
It stores the key and value states as a... | """A cache that grows dynamically as more tokens are generated. This is the default for generative models.
It stores the key and value states as a list of `CacheLayer`, one for each layer. The expected shape for each tensor
in the `CacheLayer`s is `[batch_size, num_heads, seq_len, head_dim]`.
If a config is passed, it ... | """
A cache that grows dynamically as more tokens are generated. This is the default for generative models.
It stores the key and value states as a list of `CacheLayer`, one for each layer. The expected shape for each tensor
in the `CacheLayer`s is `[batch_size, num_heads, seq_len, head_dim]`.
If a ... | import torch
from collections.abc import Iterable
from typing import Any, Optional
from .configuration_utils import PretrainedConfig | 3 | 0 | 3 | 0.666667 | true | mrahman2025/OpenClassGen | [] | ||
187 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.EncoderDecoderCache | from collections.abc import Iterable
from typing import Any, Optional
import torch
class EncoderDecoderCache(Cache):
"""
Base, abstract class for all encoder-decoder caches. Can be used to hold combinations of self-attention and
cross-attention caches.
See `Cache` for details on common methods that ar... | """Base, abstract class for all encoder-decoder caches. Can be used to hold combinations of self-attention and
cross-attention caches.
See `Cache` for details on common methods that are implemented by all cache classes.
Args:
caches (`Iterable`):
Usually an iterable of length 2, containing 2 `Cache` objec... | """
Base, abstract class for all encoder-decoder caches. Can be used to hold combinations of self-attention and
cross-attention caches.
See `Cache` for details on common methods that are implemented by all cache classes.
Args:
caches (`Iterable`):
Usually an iterable of length ... | from collections.abc import Iterable
from typing import Any, Optional
import torch | 19 | 4 | 15 | 0.631579 | true | mrahman2025/OpenClassGen | [] | ||
188 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.HQQQuantizedCache | from .configuration_utils import PretrainedConfig
class HQQQuantizedCache(QuantizedCache):
def __init__(self, config: PretrainedConfig, nbits: int=4, axis_key: int=0, axis_value: int=0, q_group_size: int=64, residual_length: int=128):
logger.warning_once("`HQQQuantizedCache` is deprecated and will be remo... | """Implement class HQQQuantizedCache.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: PretrainedConfig, nbits: int=4, axis_key: int=0, axis_value: int=0, q_group_size: int=64, residual_length: int=128)`"""
from .configuration_utils import PretrainedConfig
class HQQQuantize... |
def __init__(self, config: PretrainedConfig, nbits: int=4, axis_key: int=0, axis_value: int=0, q_group_size: int=64, residual_length: int=128):
logger.warning_once("`HQQQuantizedCache` is deprecated and will be removed in version v4.59 Use `QuantizedCache(backend='hqq', ...)` instead.")
super().__i... | from .configuration_utils import PretrainedConfig | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
189 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.HybridCache | from .configuration_utils import PretrainedConfig
class HybridCache(StaticCache):
def __init__(self, config: PretrainedConfig, max_cache_len: int, *args, **kwargs):
logger.warning_once('`HybridCache` is deprecated and will be removed in version v4.59 Use `StaticCache(...)` instead which will correctly inf... | """Implement class HybridCache.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: PretrainedConfig, max_cache_len: int, *args, **kwargs)`"""
from .configuration_utils import PretrainedConfig
class HybridCache: |
def __init__(self, config: PretrainedConfig, max_cache_len: int, *args, **kwargs):
logger.warning_once('`HybridCache` is deprecated and will be removed in version v4.59 Use `StaticCache(...)` instead which will correctly infer the type of each layer.')
super().__init__(config=config, max_cache_len=... | from .configuration_utils import PretrainedConfig | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
190 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.OffloadedCache | class OffloadedCache(DynamicCache):
def __init__(self) -> None:
logger.warning_once('`OffloadedCache` is deprecated and will be removed in version v4.59 Use `DynamicCache(offloading=True)` instead')
super().__init__(offloading=True) | """Implement class OffloadedCache.
Required methods (implement on the class; order is not specified):
- `__init__(self)`"""
class OffloadedCache: |
def __init__(self) -> None:
logger.warning_once('`OffloadedCache` is deprecated and will be removed in version v4.59 Use `DynamicCache(offloading=True)` instead')
super().__init__(offloading=True)
| 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | |||
191 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.OffloadedStaticCache | from .configuration_utils import PretrainedConfig
class OffloadedStaticCache(StaticCache):
def __init__(self, config: PretrainedConfig, max_cache_len: int, *args, **kwargs):
logger.warning_once('`OffloadedStaticCache` is deprecated and will be removed in version v4.59 Use `StaticCache(..., offloading=True... | """Implement class OffloadedStaticCache.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: PretrainedConfig, max_cache_len: int, *args, **kwargs)`"""
from .configuration_utils import PretrainedConfig
class OffloadedStaticCache: |
def __init__(self, config: PretrainedConfig, max_cache_len: int, *args, **kwargs):
logger.warning_once('`OffloadedStaticCache` is deprecated and will be removed in version v4.59 Use `StaticCache(..., offloading=True)` instead')
super().__init__(config=config, max_cache_len=max_cache_len, offloading... | from .configuration_utils import PretrainedConfig | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
192 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.QuantizedCache | from .configuration_utils import PretrainedConfig
class QuantizedCache(Cache):
"""
A quantizer cache similar to what is described in the
[KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache paper](https://huggingface.co/papers/2402.02750).
It allows the model to generate longer sequence lengt... | """A quantizer cache similar to what is described in the
[KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache paper](https://huggingface.co/papers/2402.02750).
It allows the model to generate longer sequence length without allocating too much memory for keys and values
by applying quantization.
The cache has ... | """
A quantizer cache similar to what is described in the
[KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache paper](https://huggingface.co/papers/2402.02750).
It allows the model to generate longer sequence length without allocating too much memory for keys and values
by applying quantiz... | from .configuration_utils import PretrainedConfig | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
193 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.QuantoQuantizedCache | from .configuration_utils import PretrainedConfig
class QuantoQuantizedCache(QuantizedCache):
def __init__(self, config: PretrainedConfig, nbits: int=4, axis_key: int=0, axis_value: int=0, q_group_size: int=64, residual_length: int=128):
logger.warning_once("`QuantoQuantizedCache` is deprecated and will b... | """Implement class QuantoQuantizedCache.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: PretrainedConfig, nbits: int=4, axis_key: int=0, axis_value: int=0, q_group_size: int=64, residual_length: int=128)`"""
from .configuration_utils import PretrainedConfig
class QuantoQu... |
def __init__(self, config: PretrainedConfig, nbits: int=4, axis_key: int=0, axis_value: int=0, q_group_size: int=64, residual_length: int=128):
logger.warning_once("`QuantoQuantizedCache` is deprecated and will be removed in version v4.59 Use `QuantizedCache(backend='quanto', ...)` instead.")
super... | from .configuration_utils import PretrainedConfig | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
194 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.SinkCache | class SinkCache(Cache):
"""
It is now a `custom_generate` repository on the Hub: https://huggingface.co/transformers-community/sink_cache.
See [these docs](https://huggingface.co/docs/transformers/generation_strategies#custom-decoding-methods) for
general `custom_generate`usage.
"""
def __init_... | """It is now a `custom_generate` repository on the Hub: https://huggingface.co/transformers-community/sink_cache.
See [these docs](https://huggingface.co/docs/transformers/generation_strategies#custom-decoding-methods) for
general `custom_generate`usage.
Required methods (implement on the class; order is not specified... | """
It is now a `custom_generate` repository on the Hub: https://huggingface.co/transformers-community/sink_cache.
See [these docs](https://huggingface.co/docs/transformers/generation_strategies#custom-decoding-methods) for
general `custom_generate`usage.
"""
def __init__(self, **kwargs) -> Non... | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | |||
195 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.SlidingWindowCache | from .configuration_utils import PretrainedConfig
class SlidingWindowCache(StaticCache):
def __init__(self, config: PretrainedConfig, max_cache_len: int, *args, **kwargs):
logger.warning_once('`SlidingWindowCache` is deprecated and will be removed in version v4.59 Use `StaticCache(...)` instead which will... | """Implement class SlidingWindowCache.
Required methods (implement on the class; order is not specified):
- `__init__(self, config: PretrainedConfig, max_cache_len: int, *args, **kwargs)`"""
from .configuration_utils import PretrainedConfig
class SlidingWindowCache: |
def __init__(self, config: PretrainedConfig, max_cache_len: int, *args, **kwargs):
logger.warning_once('`SlidingWindowCache` is deprecated and will be removed in version v4.59 Use `StaticCache(...)` instead which will correctly infer the type of each layer.')
super().__init__(config=config, max_cac... | from .configuration_utils import PretrainedConfig | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
196 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/cache_utils.py | transformers.cache_utils.StaticCache | from .configuration_utils import PretrainedConfig
class StaticCache(Cache):
"""
Static Cache class to be used with `torch.compile(model)` and `torch.export()`. It will check the `config`
for potential hybrid cache structure, and initialize each layer accordingly.
See `Cache` for details on common meth... | """Static Cache class to be used with `torch.compile(model)` and `torch.export()`. It will check the `config`
for potential hybrid cache structure, and initialize each layer accordingly.
See `Cache` for details on common methods that are implemented by all cache classes.
Args:
config (`PretrainedConfig`):
... | """
Static Cache class to be used with `torch.compile(model)` and `torch.export()`. It will check the `config`
for potential hybrid cache structure, and initialize each layer accordingly.
See `Cache` for details on common methods that are implemented by all cache classes.
Args:
config (`Pr... | from .configuration_utils import PretrainedConfig | 1 | 0 | 1 | 0 | true | mrahman2025/OpenClassGen | [] | ||
197 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/commands/__init__.py | transformers.commands.BaseTransformersCLICommand | from abc import ABC, abstractmethod
from argparse import ArgumentParser
class BaseTransformersCLICommand(ABC):
@staticmethod
@abstractmethod
def register_subcommand(parser: ArgumentParser):
raise NotImplementedError()
@abstractmethod
def run(self):
raise NotImplementedError() | """Implement class BaseTransformersCLICommand.
Required methods (implement on the class; order is not specified):
- `register_subcommand(parser: ArgumentParser)`
- `run(self)`"""
from abc import ABC, abstractmethod
from argparse import ArgumentParser
class BaseTransformersCLICommand: |
@staticmethod
@abstractmethod
def register_subcommand(parser: ArgumentParser):
raise NotImplementedError()
@abstractmethod
def run(self):
raise NotImplementedError()
| from abc import ABC, abstractmethod
from argparse import ArgumentParser | 2 | 0 | 2 | 0 | true | mrahman2025/OpenClassGen | [] | ||
198 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/commands/add_fast_image_processor.py | transformers.commands.add_fast_image_processor.AddFastImageProcessorCommand | from argparse import ArgumentParser, Namespace
from . import BaseTransformersCLICommand
class AddFastImageProcessorCommand(BaseTransformersCLICommand):
@staticmethod
def register_subcommand(parser: ArgumentParser):
add_fast_image_processor_parser = parser.add_parser('add-fast-image-processor')
... | """Implement class AddFastImageProcessorCommand.
Required methods (implement on the class; order is not specified):
- `register_subcommand(parser: ArgumentParser)`
- `__init__(self, model_name: str, *args)`
- `run(self)`"""
from argparse import ArgumentParser, Namespace
from . import BaseTransformersCLICommand
class ... |
@staticmethod
def register_subcommand(parser: ArgumentParser):
add_fast_image_processor_parser = parser.add_parser('add-fast-image-processor')
add_fast_image_processor_parser.add_argument('--model-name', type=str, required=True, help="The name of the folder containing the model's implementation... | from argparse import ArgumentParser, Namespace
from . import BaseTransformersCLICommand | 3 | 0 | 3 | 0 | true | mrahman2025/OpenClassGen | [] | ||
199 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/commands/add_new_model_like.py | transformers.commands.add_new_model_like.AddNewModelLikeCommand | from . import BaseTransformersCLICommand
from pathlib import Path
from argparse import ArgumentParser, Namespace
class AddNewModelLikeCommand(BaseTransformersCLICommand):
@staticmethod
def register_subcommand(parser: ArgumentParser):
add_new_model_like_parser = parser.add_parser('add-new-model-like')
... | """Implement class AddNewModelLikeCommand.
Required methods (implement on the class; order is not specified):
- `register_subcommand(parser: ArgumentParser)`
- `__init__(self, path_to_repo=None, *args)`
- `run(self)`"""
from . import BaseTransformersCLICommand
from pathlib import Path
from argparse import ArgumentPars... |
@staticmethod
def register_subcommand(parser: ArgumentParser):
add_new_model_like_parser = parser.add_parser('add-new-model-like')
add_new_model_like_parser.add_argument('--path_to_repo', type=str, help='When not using an editable install, the path to the Transformers repo.')
add_new_mo... | from . import BaseTransformersCLICommand
from pathlib import Path
from argparse import ArgumentParser, Namespace | 3 | 0 | 3 | 0 | true | mrahman2025/OpenClassGen | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.