code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils impor...
292
from ...utils import is_note_seq_available, is_transformers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: fro...
335
0
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger UpperCamelCase__ : Dict = get_logger(__name__) class _UpperCamelCase ( enum.Enum ): '''simple docstring''' ...
486
from __future__ import annotations UpperCamelCase__ : str = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def A_( A , A , A , A , A , ): UpperCAmelCase_ = [ [0 for col in range(len...
486
1
"""simple docstring""" from collections.abc import Sequence def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): return sum(c * (x**i) for i, c in enumerate(lowerCAmelCase__ ) ) def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): UpperCAmelCase_ = ...
82
'''simple docstring''' from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): ...
667
0
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def UpperCamelCase_( __magic_name__ : Union[dict, list, tuple, torch...
703
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common impor...
382
0
"""simple docstring""" import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer _A ...
505
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=snake_case__ ) class __UpperCAmelCase ( snake_case__ ): """simple docstring""" _snake_case :...
505
1
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class __magic_name__ ( _UpperCAmelCase ,unittest.TestCase ): """simple docstring""" _Up...
718
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def _lowerCamelCase ( _a , _a , _a ): """simple docstring""" _lowerCamelCase ...
297
0
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultiste...
586
"""simple docstring""" import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> Optional[An...
586
1
'''simple docstring''' import math import random def _lowerCamelCase ( lowercase : float , lowercase : bool = False ) -> float: if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value lowerCAmelCase_ : Any ...
521
'''simple docstring''' import os from datetime import datetime as dt from github import Github lowerCAmelCase_ : List[Any] = [ 'good first issue', 'feature request', 'wip', ] def _lowerCamelCase ( ) -> Dict: _a = Github(os.environ["GITH...
521
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCamelCase : Optional[int] = { "configuration_bloom": ["BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP", "BloomConfig", "Bl...
501
'''simple docstring''' __lowerCAmelCase : List[str] ="Alexander Joslin" import operator as op from .stack import Stack def UpperCamelCase ( _lowerCamelCase : str ): A__ = {"*": op.mul, "/": op.truediv, "+": op.add, "-": op.sub} A__ = Stack()...
440
0
from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def lowerCAmelCase_ ( __UpperCAmelCase: Namespace ) -> Tuple: return ConvertCommand( args.model_type , args.tf_checkpoint , args.pytorch_d...
711
import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings UpperCAmelCase_ = logg...
369
0
_lowerCamelCase : Union[str, Any] = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ _lowerCa...
87
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils...
213
0
import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO, ) __a: Dict = logging.getLog...
711
def _SCREAMING_SNAKE_CASE ( __snake_case ) -> list[int]: _UpperCAmelCase = [0 for i in range(len(__snake_case ) )] # initialize interval's left pointer and right pointer _UpperCAmelCase , _UpperCAmelCase = 0, 0 for i in range(1 , len(__sn...
402
0
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils impo...
34
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from...
533
0
# Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar __UpperCAmelCase = TypeVar('T') class A__ ( Generic[T] ): """simple docstring""" def __init...
503
from __future__ import annotations def _snake_case ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> List[Any]: """simple docstring""" print(f'''Vertex\tShortest Distance from vertex {src}''' ) for i, d in enumerate(SCREAMING_SNAKE_CASE ): print...
503
1
import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax import jit ...
413
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TableTransformerConfig""", """TableTransfor...
413
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase__ = {'''configuration_yolos''': ['''YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''YolosConfig''', '''YolosOnnxConfig''']} try: if not is_vision_availab...
702
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_devic...
408
0
"""simple docstring""" import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext...
65
"""simple docstring""" from sklearn.metrics import fa_score import datasets __UpperCAmelCase = '\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n' __UpperCAmelCase = '\nArgs...
65
1
def __lowerCAmelCase ( UpperCAmelCase__ : Any , UpperCAmelCase__ : List[Any] , UpperCAmelCase__ : List[str] = 0 , UpperCAmelCase__ : int = 0 ) -> Optional[int]: lowerCamelCase_ = right or len(_snake_case ) - 1 i...
708
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase = { '''configuration_rag''': ['''RagConfig'''], '''retrieval_rag''': ['''RagRetriever'''], '''tokenization_rag''': ['''RagTokenizer'''], } ...
103
0
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging lo...
522
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """distilbert-base...
314
0
"""simple docstring""" def _lowerCAmelCase ( __lowerCamelCase:Any ): '''simple docstring''' __magic_name__ = 1 __magic_name__ = 2 while i * i <= n: __magic_name__ = 0 while n % i == 0: ...
468
"""simple docstring""" import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from pa...
468
1
import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class __a( nn.Module ): """si...
30
import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available(): from...
30
1
# Lint as: python3 import itertools import os import re A__ : List[str] = re.compile(r'([A-Z]+)([A-Z][a-z])') A__ : Optional[Any] = re.compile(r'([a-z\d])([A-Z])') A__ : int = re.compile(r'(?<!_)_(?!_)') A__ : int = re.compile(r'(_{2,})') A__ ...
703
class _UpperCAmelCase : """simple docstring""" def __init__( self : Optional[int], lowerCamelCase : str = "", lowerCamelCase : bool = False ): '''simple docstring''' # Mapping from the first character of the prefix of the node lowercase...
671
0
"""simple docstring""" import math def UpperCamelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): return math.pow(SCREAMING_SNAKE_CASE , 2 ) - a def UpperCamelCase (SCREAMING_SNAKE_CASE ): return 2 * x def UpperCamelC...
102
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline _UpperCAmelCase = logging.get_logger(__name__) # pylint: disable=invalid-name class snake_case_ ( __lowercase...
504
0
'''simple docstring''' # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer ...
720
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() _lowerCAmelCase : List[str] = logging.get_logger('transformers.models.speecht5') def __UpperCamelCase ( _A : Any...
646
0
def lowerCamelCase__ ( __lowerCAmelCase : Dict , __lowerCAmelCase : List[str] , __lowerCAmelCase : Optional[Any] , __lowerCAmelCase : Any ): """simple docstring""" global f # a global dp table for knapsack if f[i][j] < 0: if j...
290
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class _lowerCAmelCase ( __a ): _lowercase =4...
290
1
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor lowercase : List[str] = logging.get_logger(__name__) class A__ ( __UpperCAmelCase ): """simple docstring""" def __init__( self , *lowercase , ...
392
import collections import os import re from pathlib import Path lowercase : int = """src/transformers""" # Matches is_xxx_available() lowercase : List[str] = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} lowercase : str = re.compil...
392
1
"""simple docstring""" import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import...
4
"""simple docstring""" from __future__ import annotations import requests def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : str ): lowerCAmelCase = F'https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty' return requests.get(_UpperCAmelCase ).json() def _SCREAMING_SNAKE_C...
4
1
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transformers.util...
456
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor lowercase_ = logging.get_logger(__name__) class __a ( SCREAMING_SNAKE_CASE ): def __init__( self : Optional[Any] , *snake_case_ : List[str] ,...
456
1
import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def __SCREAMING_SNAKE_CASE ( a__ : Optional[int] ,a__ : Any ) ...
17
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_fnet import F...
31
0
'''simple docstring''' from __future__ import annotations from dataclasses import dataclass @dataclass class __SCREAMING_SNAKE_CASE : snake_case_ = 42 snake_case_ = None snake_case_ = None def _a( UpperCamelCase__ ...
709
'''simple docstring''' import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_...
665
0
import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def __magic_name__ ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE=1_024 , SCREAMING_SNAKE_CASE=...
66
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers.ut...
383
0
import functools def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): # Validation if not isinstance(_lowerCamelCase , _lowerCamelCase ) or not all(isinstance(_lowerCamelCase , _lowerCamelCase ) for day in days ): raise ValueError("The parameter days shou...
718
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
37
0
import math from collections.abc import Callable def UpperCamelCase ( __magic_name__ : Callable[[float], float] , __magic_name__ : float , __magic_name__ : float ) -> float: """simple docstring""" lowercase__ = xa lowercase_...
15
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A = logging.get_logger(__name__) A = { "facebook/deit-base-distilled-patch16-22...
475
0
"""simple docstring""" import sys import turtle def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : tuple[float, float] , SCREAMING_SNAKE_CASE : tuple[float, float] ): '''simple docstring''' return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def UpperCAmelCa...
393
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { "kss...
393
1
import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTeste...
64
from __future__ import annotations from typing import Any class _snake_case ( snake_case ): pass class _snake_case : def __init__( self , _a ): __magic_name__ : Any = data __magic_name__ : Node | None = None def __it...
124
0
"""simple docstring""" import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py __SCREAMING_SNAKE_CASE : Any = '''src/trans...
623
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __SCREAMING_SNAKE_CASE : Optional[Any] = { '''configuration_vision_encoder_decoder''':...
623
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """YituTech/conv-bert-base""": """https://huggingface.co/YituTech/c...
74
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_di...
483
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctct''': ['''MCTCTFeatu...
280
'''simple docstring''' class lowercase : """simple docstring""" def __init__( self , UpperCamelCase_ = "" , UpperCamelCase_ = False ): '''simple docstring''' UpperCamelCase__ :dict[str, RadixNode] = {} # A node will be a leaf if the tree ...
280
1
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.t...
27
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependen...
507
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCAmelCase : Union[str, Any] = logging.get_logger(__name__) UpperCAmelCase : Dict ...
299
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( CenterCrop, Compose, Normaliz...
299
1
'''simple docstring''' import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging i...
688
'''simple docstring''' import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node __SCREAMING_SNAKE_CASE = 4 __SCREAMING_SNAKE_CASE = 3 class low...
688
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { '''microsoft/wavlm-base''': '''https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json''', #...
452
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vis...
452
1
'''simple docstring''' from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image ...
207
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class a ( snake_case__ ): '''simple docstring''' __lowerCAmelCase : Optional[int] = """ClapFeatureExtractor""" __lowerCAmelCase : str = (...
120
0
from ...configuration_utils import PretrainedConfig __A : str = { "google/tapas-base-finetuned-sqa": ( "https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json" ), "google/tapas-base-finetuned-wtq": ( "https://huggingface.co/google/tapas-base-finetun...
715
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __A : Any = { 'configuration_longt5': ['LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LongT5Config', 'LongT5OnnxConfig'], } try: if not is_torch_available(): ...
698
0
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimension ...
397
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import Confi...
397
1
'''simple docstring''' from collections.abc import Generator def SCREAMING_SNAKE_CASE( ) -> Generator[int, None, None]: UpperCAmelCase_ , UpperCAmelCase_ : Optional[int] = 0, 1 while True: UpperCAmelCase_ , UpperCAmelCase_ : str = b, a ...
471
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { "facebo...
471
1
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that...
105
import logging import os import threading import time try: import warnings except ImportError: a__ : Optional[Any] = None try: import msvcrt except ImportError: a__ : List[str] = None try: import fcntl except ImportError: a__ : O...
188
0
def __UpperCAmelCase ( UpperCAmelCase )-> float: """simple docstring""" if edge <= 0 or not isinstance(UpperCAmelCase, UpperCAmelCase ): raise ValueError('''Length must be a positive.''' ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) ...
707
from __future__ import annotations from collections.abc import MutableSequence class __lowercase : def __init__( self : Optional[Any] , __lowerCamelCase : int , __lowerCamelCase : MutableSequence[float] ) -> None: '...
479
0
"""simple docstring""" def SCREAMING_SNAKE_CASE ( snake_case): assert isinstance(lowerCamelCase_, lowerCamelCase_), f"The input value of [n={number}] is not an integer" if number == 1: return 2 elif number < 1: __snake_case = f"The input value of [n={numb...
564
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class lowerCamelCase__ ( lowerCamelCase__): '''simple docstring''' def __init__(self ...
647
0
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dat...
198
import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py a__ = """src/diffusers""" # Matches is_xxx_available() a__ = re.compile(R"""is\_([a-z_]*)_available\(\)""") # Matches ...
198
1
def SCREAMING_SNAKE_CASE ( snake_case_ : list[list[int | float]] ): snake_case__ : Optional[int] = len(lowerCAmelCase__ ) snake_case__ : str = len(matrix[0] ) snake_case__ : Union[str, Any] = min(lowerCAmelCase__ , lowerCAmelCase__ ) for row in range(lowerCAmel...
297
"""simple docstring""" import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class __UpperCAmelCase ( _UpperCamelCase ): # to overwrite a...
642
0
'''simple docstring''' import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging A =logging.get_logger(__name__) A ={'voca...
358
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging A =logging.get_logger(__name__) A ={ 'facebook/encodec_24khz': 'https://huggingface.co/facebook/encodec_24khz/resolve/ma...
358
1
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class UpperCamelCase : '''simple docstring''' lowercase : int lowercase : int ...
257
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def UpperCamelCase ( _a ) -> List[str]: '''simple docstri...
257
1
'''simple docstring''' import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling...
630
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Optional[int] = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], ...
630
1
'''simple docstring''' import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _...
430
'''simple docstring''' def __lowerCamelCase ( A__ ) -> bool: """simple docstring""" if num < 0: return False UpperCamelCase = num UpperCamelCase = 0 while num > 0: UpperCamelCase = rev_nu...
430
1
'''simple docstring''' from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class UpperCamelCase__ ( _UpperC...
713
'''simple docstring''' import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclas...
609
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __UpperCAmelCase = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try: if not is_...
329
'''simple docstring''' import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import Backbo...
329
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase : Optional[Any] = { 'c...
432
'''simple docstring''' import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, ...
432
1
"""simple docstring""" import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calcul...
420
"""simple docstring""" from queue import PriorityQueue from typing import Any import numpy as np def lowercase ( a__ : dict , a__ : str , a__ : set , a__ : set , a__ : dict , a__ : dict , a__ : ...
420
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class snake_case ( metaclass=lowerCAmelCase__): __UpperCamelCase = ["torch", "torchsde"] def __init__( self : Optional[Any] , *a__ : str , **a__ : str ...
709
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { "Salesforce/blip-vqa-base": "https://huggingface.co/Salesforce/bli...
621
0
a__ : Optional[int] = """Tobias Carryer""" from time import time class lowercase : """simple docstring""" def __init__( self : int , a_ : Union[str, Any] , a_ : int , a_ : List[Any] , a_ : List[str]=in...
165
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a__ : Any = { """configuration_wav2vec2""": ["""WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Wav2Vec2Conf...
165
1
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : int )-> bool: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
222
"""simple docstring""" import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __a ( lowerCAmelCase__ , unitte...
222
1
import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def UpperCAmelCase_ ( UpperCAmelCase__ ): return np.dot(UpperCAmelCase__ , UpperCAmelCase__ ) class UpperCamelCase__ : def __init__( self : Any , *, ...
412
import re def UpperCAmelCase_ ( UpperCAmelCase__ ): lowercase_ = re.compile(r"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$""" ) if match := re.search(UpperCAmelCase__ , UpperCAmelCase__ ): return match.string == phone return False if __name__ == "__main__": pri...
412
1
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : Any = {'configuration_focalnet': ['FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FocalNetConfig']} try: if not...
712
'''simple docstring''' import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import class...
126
0
'''simple docstring''' import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE = logging.get_logger(__name__) def snake_case_ ( lowe...
199
'''simple docstring''' import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from trans...
199
1
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _inter...
467
import fire from utils import calculate_rouge, save_json def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: int , lowerCAmelCase: Tuple , lowerCAmelCase: Any=None , **lowerCAmelCase: Any ) -> Dict: _UpperCAmelCase : Optional[Any] = [x.strip() for x in open(low...
467
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A_ = {"""configuration_reformer""": ["""REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Refor...
42
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : int = logging.get_logger(__name__) __a : Optional[int] = { """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/resolve/main/config.json""", # See all PEGASUS models at htt...
534
0
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteSched...
711
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosity_info() __lowerCAmelCase ...
164
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a : List[str] = logging.get_logger(__name__) a : Optional[Any] = { "microsoft/unispeech-large-1500h-cv": ( "https://huggingface.co/mi...
63
'''simple docstring''' import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetV...
448
0
'''simple docstring''' def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : int = 1000 ) -> int: UpperCAmelCase_ , UpperCAmelCase_ : Optional[Any] = 1, 1 UpperCAmelCase_ : List[str] = [] for i in range(1, n + 1 ): ...
644
'''simple docstring''' snake_case_ : int = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0...
644
1
'''simple docstring''' # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union UpperCAmelCase = re.compile(r'''^(?P<major>\d+)''' r'''\.(?P<minor>\d+)''' r'''\.(?P<patch>\d+)$''') @total_ordering @dataclass cla...
119
'''simple docstring''' import os from collections.abc import Iterator def __UpperCamelCase ( lowercase__ : str = "." ): '''simple docstring''' for dir_path, dir_names, filenames in os.walk(lowercase__ ): __lowercase =[d for d in dir_names if d != 'scripts' a...
119
1
lowerCAmelCase__ = "\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" lowerCAmelCase__ = [{"type": "code", "content": INSTALL_CONTENT}] lowerCAmelCase__ = { "...
1
def _lowerCAmelCase( __A , __A , __A ): if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(__A , n - 1 , __A ) * a) % mod else: UpperCAmelCase = binary_exponentiation(__A , n / 2 , __A ) return (b * b) % mod ...
1
1
'''simple docstring''' from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils i...
26
# Copyright (c) 2021-, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
327
0
'''simple docstring''' import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( ...
719
'''simple docstring''' import sys from collections import defaultdict class __UpperCAmelCase : def __init__( self ): lowerCAmelCase_ = [] def UpperCAmelCase_ ( self , _lowerCamelCase ): return self.node_position[vertex] def Uppe...
606
0
'''simple docstring''' import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin ...
331
'''simple docstring''' from math import pi def _lowerCAmelCase (_lowercase , _lowercase ): """simple docstring""" return 2 * pi * radius * (angle / 3_60) if __name__ == "__main__": print(arc_length(90, 10))
331
1
'''simple docstring''' import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex UpperCAmelCase = logging.getLogger(__name__) class __snake_case: '''simple docstring'...
344
'''simple docstring''' def _snake_case ( _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : float ) -> float: """simple docstring""" if density <= 0: raise ValueError("""Impossible fluid density""" ) if bulk_modulus <= 0: raise ValueError("""Im...
344
1
"""simple docstring""" import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import To...
575
from typing import Dict, Optional import numpy as np import datasets a__ : int = """ IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union between the predicted segmentation and the ground truth. For binary (two classes) or multi-cla...
165
0
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax...
718
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, ...
10
0
'''simple docstring''' import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf ...
26
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner ...
61
0
"""simple docstring""" from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": lowercase__ : str = input('''Enter image url: ''').strip() print(f'Downloading image from {url} ...') lowercase__ : Dict = Beaut...
711
"""simple docstring""" from statistics import mean, stdev def __lowercase ( _a , _a = 3 ): snake_case_ : Optional[int] = min(_a ) snake_case_ : str = max(_a ) # normalize data return [round((x - x_min) / (x_max - x_min) , _a ) for x in data...
485
0
'''simple docstring''' from __future__ import annotations __magic_name__ = 1.60_21e-19 # units = C def lowerCamelCase ( lowerCamelCase : float , lowerCamelCase : float , lowerCamelCase : float , ): if (conductivity, electron_conc, mobility).count(0) != 1: ...
665
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils i...
665
1
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
704
import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets _UpperCamelCase : Optional[int] = datasets.logging.get_logger(__name__) _UpperCamelCase : Dict = """\ @inproceedings{bleurt, title={BLEURT: Learning Robust ...
341
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) f...
587
import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_image from ...image_u...
587
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise OptionalDependencyN...
125
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_...
125
1
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline snake_case : List[str] = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) parser.add_argument("--dpm", action=...
124
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_te...
124
1
'''simple docstring''' import math def lowerCAmelCase_ ( snake_case_ : int , snake_case_ : Dict ) -> List[Any]: '''simple docstring''' return math.pow(UpperCAmelCase__ , 2 ) - a def lowerCAmelCase_ ( snake_case_ : Union[st...
714
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
415
0
'''simple docstring''' __UpperCAmelCase ="\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" __UpperCAmelCase...
546
'''simple docstring''' from manim import * class a__ ( UpperCAmelCase__ ): def SCREAMING_SNAKE_CASE__ ( self : List[Any] ): """simple docstring""" __lowerCamelCase = Rectangle(height=0.5 , width=0.5 ) _...
546
1
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path UpperCAmelCase_ = Path(__file__).resolve().parents[3] / 'src' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noqa im...
707
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class lowerCamelCase__( ...
80
0
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ ): '''simple docstring''' if nth_term == "": return [""] __SCREAMING_SNAKE_CASE = int(lowerCAmelCase_ ) __SCREAMING_SNAKE_CASE = ...
682
"""simple docstring""" from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAtte...
682
1
"""simple docstring""" def __a ( A ) -> int: '''simple docstring''' if not isinstance(A , A ): A__ = f"""Input value of [number={number}] must be an integer""" raise TypeError(A ) if number < 1: A__ = f"""Input value of [number={number}] mus...
261
"""simple docstring""" import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCAmelCase =logging.get_logger(__name__) __UpperCAmelCase =...
261
1
"""simple docstring""" from __future__ import annotations lowerCAmelCase = 1.6_021E-19 # units = C def lowerCAmelCase_ ( snake_case_ : float , snake_case_ : float , snake_case_ : float , ) ->str: if (conductivity, e...
174
"""simple docstring""" from itertools import permutations def lowercase ( _SCREAMING_SNAKE_CASE : tuple ): '''simple docstring''' if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False ...
602
0
"""simple docstring""" import pytest _lowercase = '''__dummy_dataset1__''' _lowercase = ''' import json import os import datasets REPO_URL = "https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/" URLS = {"train": REPO_URL + "wikiann-bn-train.jsonl", "validation"...
22
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class lowerCAmelCase_ : '''simple docstring''' def __init__( self : Dict ) -> int: A = {} def _SCREAMING_SNAKE_...
22
1
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
285
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecate...
285
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase_ = { '''configuration_canine''': ['''CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CanineConfig'''], '''tokenization_canine''': ['''Can...
336
import math import random def lowerCAmelCase ( UpperCAmelCase, UpperCAmelCase = False ) ->float: """simple docstring""" if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value lowercase...
336
1
from __future__ import annotations import math def _SCREAMING_SNAKE_CASE ( lowerCAmelCase__ ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not ...
364
def _SCREAMING_SNAKE_CASE ( lowerCAmelCase__=2_81_23 ): lowerCamelCase_ : Any = [1] * (limit + 1) for i in range(2 ,int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 ,limit // i + 1 ): sum_divs[k * i] += k + i ...
364
1
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def lowerCamelCase ( _UpperCamelCase : int = 3 ) -> qiskit.result.counts.Counts: '''simple docstring''' if isinstance(_UpperCamelCase , _UpperCamelCase ...
717
"""simple docstring""" import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterM...
299
0
import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def __snake_case ( __UpperCamelCase : Optional[int] ): """simple docstring""" if "img_encoder.pos_embed" in name: A_ ...
86
'''simple docstring''' import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer __SCREAMING_SN...
244
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device a_ = False class __lowercase ( unittest.TestCase): ...
48
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING a_ = logging.get_logger(__name__) class __lowercase ( _UpperCAmelCase): """simple docstring""" ...
48
1
"""simple docstring""" import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_...
633
"""simple docstring""" import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging a : List[Any] = '''\ ''' a : Optional[int] = ''' Perpl...
633
1
import math def __lowercase ( UpperCAmelCase__ , UpperCAmelCase__ ): """simple docstring""" return math.pow(UpperCAmelCase__ , 2 ) - a def __lowercase ( UpperCAmelCase__ ): """simple docstring""" return 2 * x def __lowercase...
710
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from datas...
102
0