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 import tempfile import datasets from utils import generate_example_dataset, get_duration __lowerCamelCase = 5_00_00 __lowerCamelCase = 50_00 __lowerCamelCase , __lowerCamelCase = os.path.split(__file__) __lowerCamelCase =...
490
"""simple docstring""" import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __lowercase ( _UpperCAmelCase): """simple docstring""" @require_torch ...
480
0
import sys def UpperCamelCase_( _A :Union[str, Any] )-> Dict: UpperCamelCase__ = len(lowerCAmelCase_ ) UpperCamelCase__ = [[0 for x in range(lowerCAmelCase_ )] for x in range(lowerCAmelCase_ )] UpperCamelCase__ = [[0 for x in range(lowerCAmelCase_ )] for x ...
707
from __future__ import annotations import numpy as np def UpperCamelCase_( _A :list[float] )-> Union[str, Any]: return np.maximum(0 , _A ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
185
0
from typing import Dict, Iterable, 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_cha...
144
# using dfs for finding eulerian path traversal def SCREAMING_SNAKE_CASE ( __UpperCamelCase : List[Any] , __UpperCamelCase : int , __UpperCamelCase : List[str] , __UpperCamelCase : List[str]=None ) -> Optional[Any]: UpperCAmelCase_ = (path or [])...
144
1
import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from transformers import DPRContext...
706
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """google/switch-base-8""": """https://huggingface.co/google/switch-base-8/blob/main/config.json""", } class __UpperCamelCase ( lowerCAme...
131
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase : str = {"""configuration_xglm""": ["""XGLM_PR...
671
from __future__ import annotations from math import ceil, floor, sqrt def A_ ( _UpperCAmelCase = 2_00_00_00 ): SCREAMING_SNAKE_CASE_: list[int] = [0] SCREAMING_SNAKE_CASE_: int for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ...
671
1
import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from tra...
718
from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy UpperCamelCase__ : List[str] = logging.get_logger(...
486
0
from ..utils import DummyObject, requires_backends class lowerCamelCase (metaclass=__UpperCAmelCase ): """simple docstring""" lowerCamelCase__ = ['torch'] def __init__( self : int , *__magic_name__ : Optional[Any] , **__magic_name__ : int ) -> Opt...
140
from decimal import Decimal, getcontext from math import ceil, factorial def _UpperCAmelCase ( UpperCamelCase: int ): """simple docstring""" if not isinstance(UpperCamelCase , UpperCamelCase ): raise TypeError("Undefined for non-integers" ) elif precision < 1: raise ValueError("Und...
611
0
import heapq import sys import numpy as np _UpperCAmelCase : str = tuple[int, int] class lowercase : def __init__( self ): snake_case_ = [] snake_case_ = set() def a ( self ): if not self.e...
108
_UpperCAmelCase : str = [0, 2, 4, 6, 8] _UpperCAmelCase : Any = [1, 3, 5, 7, 9] def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' if remaining_len...
108
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __snake_case: Any = {"configuration_plbart": ["PLBART_PRETRAINED_CON...
577
'''simple docstring''' from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class _UpperCAmelCase ( lowerCAmelCase__ ): ""...
577
1
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass a__ : List[str] = (3, 9, -1_1, 0, 7, 5, 1, -1) a__ : Optional[int] = (4, 6, 2, 0, 8, 1_0, 3, -2) @dataclass class lowercase_ : __UpperCAmelCase = 42 ...
710
'''simple docstring''' import comet # From: unbabel-comet import torch import datasets a__ : int = datasets.logging.get_logger(__name__) a__ : Union[str, Any] = '\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and ...
223
0
from __future__ import annotations from collections.abc import Sequence from typing import Literal def UpperCamelCase__ ( UpperCAmelCase_ , UpperCAmelCase_ ) -> Tuple: '''simple docstring''' _lowercase : List[str] = list(lowercase__ ) ...
322
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __lowercase : Tuple =logging.get...
54
0
def _lowerCamelCase ( snake_case = 50_000_000 ): _lowerCAmelCase = set() _lowerCAmelCase = int((limit - 24) ** (1 / 2) ) _lowerCAmelCase = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in ra...
225
import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from .....
225
1
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> List[Any]: '''simple docstring''' lowercase_ = [False] * len(__lowerCAmelCase ) lowercase_ = [] qu...
567
"""simple docstring""" import sys import turtle def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase ) -> tuple[float, float]: '''simple docstring''' return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def _SCREAMING_SNAKE_CASE (__lowerCAmelC...
567
1
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class a : """simple docstring""" def __init__( self , lowerCAmelCase_ = None ) -> None: if component...
704
def snake_case ( snake_case__ :int = 1_000_000) -> int: _A = set(range(3 , snake_case__ , 2)) primes.add(2) for p in range(3 , snake_case__ , 2): if p not in primes: continue primes.difference...
83
0
'''simple docstring''' import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger snake_case_ : str = get_logger(__name__) snake_case_ : List[str] = R''' Args: input_ids (`...
138
'''simple docstring''' # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def lowercase__( _UpperCamelCase : Optional[Any] , _UpperCamelCase : Dict , _UpperCamelCase : int , _UpperCamelCase : Optional[int] )-> List[Any]: """simple docstring""" _...
138
1
import cmath import math def __lowerCAmelCase ( UpperCAmelCase__ : float , UpperCAmelCase__ : float , UpperCAmelCase__ : float , UpperCAmelCase__ : float ) -> str: lowerCamelCase_ = math.radians(__UpperCamelCase ...
721
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...tes...
103
0
'''simple docstring''' import functools from typing import Any def a_ ( _UpperCAmelCase : str ,_UpperCAmelCase : list[str] ) -> List[str]: if not isinstance(lowercase__ ,lowercase__ ) or len(lowercase__ ) == 0: raise ValueError('the string should be no...
286
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable SCREAMING_SNAKE_CASE__ : Any = {"configuration_dpt": ["DPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DPTConfig"]...
85
0
from numpy import exp, pi, sqrt def __lowerCamelCase ( lowerCamelCase__ , lowerCamelCase__ = 0.0 , lowerCamelCase__ = 1.0 ): """simple docstring""" return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if __name__ == "__main__": import doctest ...
81
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( ...
81
1
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class lowerCamelCase( __sn...
27
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class lowerCAmelCase__ ( _lowerCamelCase ): '''si...
265
0
'''simple docstring''' def lowerCAmelCase( a__ : str , a__ : int ): '''simple docstring''' lowerCamelCase__ = [[] for _ in range(A__ )] lowerCamelCase__ = key - 1 if key <= 0: raise ValueError(...
714
'''simple docstring''' from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function lowerCAmelCase_ = 1.0_5457_1817E-34 # unit of ℏ : J * s lowerCAmelCase_ = 3E8 # unit of c : m * s^-1 ...
426
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Union[str, Any] = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extra...
689
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) _a :...
689
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import DistilBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor,...
663
"""simple docstring""" from PIL import Image def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Image ,_lowerCamelCase : int ) -> Image: _lowerCAmelCase : Any = (259 * (level + 255)) / (255 * (259 - level)) def contrast(_lowerCamelCase : int ) -> int: return int(128 + facto...
663
1
def _a ( UpperCAmelCase ) -> int: """simple docstring""" assert isinstance(UpperCAmelCase , UpperCAmelCase ), f"The input value of [n={number}] is not an integer" if number == 1: return 2 elif number < 1: lowerCamelCase__ : List[str] = f"The in...
315
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _A : Any = logging.get_logger(__name__) _A : str = [ ['attention', 'attn'], ['encoder_at...
315
1
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ) from diffusers.pipel...
716
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_camembert i...
106
0
from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy a_ = logging.get_logger(__name__) class __lowerCAmelCas...
175
def lowerCamelCase_ ( UpperCAmelCase__ = 100 ): """simple docstring""" a_ = (n * (n + 1) // 2) ** 2 a_ = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(F'''{solution() = }''')
483
0
"""simple docstring""" def lowerCamelCase_ ( UpperCAmelCase_ ) ->Any: if not nums: # Makes sure that the list is not empty raise ValueError('''List is empty''' ) __UpperCAmelCase : str = sum(UpperCAmelCase_ ) / len(UpperCAmelCase_ ) # Calcu...
714
"""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 lowercase__ :int = 'sr...
374
0
"""simple docstring""" import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common impor...
76
'''simple docstring''' # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for te...
688
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCamelCase__ ( UpperCAmelCase ): """simple docstring""" _UpperCamelCase : List[str] = ['image_processor', 'tokenizer'] _UpperCamelCase ...
185
from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCamelCase__ ( UpperCAmelCase ): """simple docstring""" @staticmethod @abstractmethod def snake_case__ ( snake_case ): '''simple docstring''' raise NotImp...
185
1
"""simple docstring""" from __future__ import annotations from typing import Any class snake_case_ : """simple docstring""" def __init__( self , lowerCamelCase_) -> None: UpperCamelCase = num_of_nodes UpperCamelCase = [] ...
34
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def __snake_case ( _lowercase ): """simple docstring""" if "cls_token" in name: UpperCamelCas...
34
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { "google/switch-base-8": "https://huggingface.co/google/switch-base-8/blob/main/config.json", } class UpperCAmelCase_ ( a): lowerCamelCase__...
658
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py _snake_case = "\\n@INPROCEEDINGS{Papineni02bleu:a,\n author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu},\n title = {BLEU: a Method for Automatic Evalua...
658
1
from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __UpperCAmelC...
99
class UpperCAmelCase_ : def __init__( self , _lowerCAmelCase ): # we need a list not a string, so do something to change the type UpperCAmelCase__ : Dict = arr.split(""",""" ) def __UpperCAmelCase ( self ): ...
79
0
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 lowerCamelCase : int = logging.get_logger(__name__) lowerCamelCase : Any = ...
707
def snake_case_ ( lowerCAmelCase_ : int , lowerCAmelCase_ : int ): return int((input_a, input_a).count(0 ) == 0 ) def snake_case_ ( ): assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 )...
649
0
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.convers...
427
'''simple docstring''' import random from .binary_exp_mod import bin_exp_mod def UpperCamelCase_ ( snake_case_ : str , snake_case_ : List[str]=10_00 ) -> Dict: '''simple docstring''' if n < 2: return False if n % 2 == 0: return n == 2 # this means...
427
1
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modelin...
704
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" SCREAMING_SNAKE_CASE = '''ClapFeatureExtractor''' SCREAMING_SNAKE_CASE ...
329
0
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING __lowerCamelCase ...
96
from __future__ import annotations import math def snake_case__ ( UpperCAmelCase : int ): if num <= 0: lowerCAmelCase__ :Optional[Any] = F'''{num}: Invalid input, please enter a positive integer.''' raise ValueError(UpperCAmelCase ) lowerCAmelCase_...
145
0
# Copyright 2022 The HuggingFace Team and The OpenBMB 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 ...
356
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class lowerCamelCase (yaml.SafeLoader ): """simple docstring""" def __A ( self : str , __magic_name__ : str ) -> str: SCREAMING_SNAKE_CASE_ = ...
356
1
"""simple docstring""" from __future__ import annotations def _a ( _snake_case , _snake_case , _snake_case , _snake_case ): """simple docstring""" if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and array[indexa] < array[index...
341
"""simple docstring""" import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class lowerCamelCase__ ( snake_case ): ...
341
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __A : List[str] = {"""configuration_speech_encoder_decoder""": ["""SpeechEncoderDecoderConfig"""]} try: if not is_torch_available(): raise OptionalDep...
450
import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup __A : int = { """User-Agent""": """Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36""" """ (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582""" }...
450
1
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaTokenizer else: __snake_...
540
import logging 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, BertEncoder, ...
540
1
'''simple docstring''' import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device...
721
'''simple docstring''' from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .atte...
389
0
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_...
182
"""simple docstring""" import requests def a__ ( lowerCAmelCase , lowerCAmelCase ) -> None: UpperCAmelCase__ : List[str] = {"""Content-Type""": """application/json"""} UpperCAmelCase__ : List[str] = requests.post(lowerCAmelCase , json={"""text"""...
182
1
import argparse import os import re import packaging.version __UpperCamelCase : Any = "examples/" __UpperCamelCase : Tuple = { "examples": (re.compile(r"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": ...
106
__UpperCamelCase : List[Any] = 256 # Modulus to hash a string __UpperCamelCase : Union[str, Any] = 100_0003 def _a ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : str ): """simple docstring""" UpperCamelCase__ : Optio...
106
1
'''simple docstring''' import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transfor...
330
'''simple docstring''' import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random...
330
1
from math import pow, sqrt def __A ( *_SCREAMING_SNAKE_CASE : float ): """simple docstring""" __SCREAMING_SNAKE_CASE : List[str] = len(_SCREAMING_SNAKE_CASE ) > 0 and all(value > 0.0 for value in values ) return ...
700
'''simple docstring''' from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig lowercase = logging.get_logger(__name__) lowercase = '''T5Config''' class __lowerCamelCase ...
564
0
"""simple docstring""" import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup UpperCAmelCase__ = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" " (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582"...
277
"""simple docstring""" import json import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProces...
289
0
'''simple docstring''' import requests from bsa import BeautifulSoup def __UpperCAmelCase ( __magic_name__ = "AAPL" )-> str: """simple docstring""" snake_case_ : int = F'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' snake_case_ ...
718
'''simple docstring''' import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrFor...
656
0
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def _lowerCAmelCase ( __magic_name__ : List[str] ) -> Union[str, Any]: # This defines a "chinese character" as anything in the CJK Unicode ...
92
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, Wava...
92
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """facebook/c...
717
"""simple docstring""" from __future__ import annotations import math import random from typing import Any class a : def __init__( self : str ) -> None: '''simple docstring''' SCREAMING_SNAKE_CASE_: list[Any] =[] SCREAMING_SNAKE_CASE_: ...
36
0
'''simple docstring''' import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() ...
301
"""simple docstring""" import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .ut...
174
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResa...
38
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowerCamelCase : Union[str, Any] = { """configuration_vision_encoder_decoder""": ["""VisionEncoderDecoderConfig""",...
38
1
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTe...
454
'''simple docstring''' from __future__ import annotations import numpy as np def _lowerCAmelCase (_lowercase ): """simple docstring""" return np.maximum(0 , _lowercase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, ...
331
0
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import...
616
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torc...
616
1
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer else: SCREAMI...
99
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from ...
174
0
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data...
720
from __future__ import annotations def lowercase_ ( __snake_case : list ) -> float: '''simple docstring''' if not nums: raise ValueError("List is empty" ) return sum(__snake_case ) / len(__snake_case ) if __nam...
57
0
'''simple docstring''' from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_ut...
430
'''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/LI...
430
1
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nes...
411
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, ...
411
1
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokeniz...
168
'''simple docstring''' import os import sys import unittest _a : Optional[int] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402...
168
1
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered # since...
685
from typing import TYPE_CHECKING from ....utils import _LazyModule UpperCamelCase__ : Tuple = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys UpperCamelCase__ : int = _LazyModule...
685
1
from __future__ import annotations __A : str = list[tuple[int, int]] __A : Optional[int] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [...
16
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer __A : str = logging.get_logger(__name__) _...
16
1
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class a ( unittest.TestCase ): def snake_case_ ( self ): """simple docstring""" __SCREAMING_SNAKE_CASE: Any = [ 'safety_checker...
706
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...
146
0
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) __magic_name__ = 299_792_458 # Symbols __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ = symbols('''ct x y z''') def SCREAMING_SNAKE_CASE__ ...
276
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_tor...
276
1
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...
194
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install...
194
1
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def lowercase ( __A : Union[str, Any] ) -> Any: '''simple docstring''' if "cls_token" in name: snake_case : ...
36
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version lowercase_ = { "<": operator.lt, "<=": operator.le, "==": operator.eq, "!=": operator.ne, ">=": operator.ge, ">...
695
0
'''simple docstring''' # flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFormatter, format_tabl...
581
'''simple docstring''' import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets SCREAMING_SNAKE_CASE__ : Any = ''' @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translation for Text Sim...
581
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) _UpperCamelCase : List[Any] = { """configuration_trocr""": ["""TROCR_PR...
284
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Union[str, Any] = logging.get_logger(__name__) a_ : Optional[int] = { """BAAI/AltCLIP""": """https://huggingface.co/BAAI/AltC...
676
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "google/fnet-large": "https://huggingface.co/...
92
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, P...
92
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase = { '''configuration_roberta_prelayernorm''': [ '''ROBERTA_PREL...
211
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def __A ( _SCREAMING_SNAKE_CASE : Tuple ): """simple docstring""" if "img_enco...
211
1
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_de...
716
'''simple docstring''' from __future__ import annotations import unittest from transformers import DistilBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, id...
654
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __snake_case (__UpperCAmelCase ): lowerCAmelCase__ = ["image_processor", "tokenizer"] lowerCAmelCase__ = "CLIPImageProcessor" lowerCAmelCase__ ...
429
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class SCREAMING_SNAKE_CASE__ ( ctypes.Structure ): # _fields is a specific attr expected by ctypes ...
567
0
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( snake_case_ : str ) -> list[int]: SCREAMING_SNAKE_CASE : Dict = [0 for i in range(len(snake_case_ ) )] # initialize interval's left pointer and right pointer SCREAMING_SNAKE_CASE , SCREA...
220
'''simple docstring''' import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging __UpperCAmelCase = '\\n\n' __UpperCAmelCase = '\nPerplexity (PPL) is one of the most comm...
220
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase_ = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltCLIPTextConfig", ...
32
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Ac...
15
0
"""simple docstring""" import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversati...
712
"""simple docstring""" from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record __magic_name__ = "\\n@article{wang2019superglue,\n title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems},\n author...
248
0
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def lowerCamelCase__ ( _lowercase ): ...
30
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_dat...
154
0
"""simple docstring""" import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils...
706
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( ...
16
0
"""simple docstring""" import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_tor...
96
"""simple docstring""" from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, g...
259
0
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py a : Optional[int] = '''src/diff...
704
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : List[str] = { '''configuration_table_transformer''': [ '''TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TableTransformerConfig''', '''TableTransformerO...
527
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a : Any = { 'configuration_vision_encoder_decoder': ['VisionEncoderDecoderConfig', 'VisionEncoderDe...
556
def lowerCAmelCase_ (lowerCAmelCase__: list ): """simple docstring""" if len(lowerCAmelCase__ ) <= 1: return [tuple(lowerCAmelCase__ )] UpperCAmelCase_: List[Any] = [] def generate(lowerCAmelCase__: int , lowerCAmelCase__: list ): if...
556
1
"""simple docstring""" import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def lowercase (SCREAMING_SNAKE_CASE_ : List[A...
327
"""simple docstring""" import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow...
327
1
"""simple docstring""" import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import ex...
564
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_image_siz...
285
0
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class UpperCAmelCase__ ( __snake_case ...
332
import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data import ...
332
1
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class __SCREAMING_SNAKE_CASE ( unittest.TestCase ): _UpperCAmelCase : Tuple = JukeboxTokenizer _UpperCAmelCase : int = { ""...
315
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class _lowerCAmelCase ( UpperCAmelCase_ , unittes...
411
0
'''simple docstring''' from string import ascii_uppercase a__ = {str(ord(c) - 55): c for c in ascii_uppercase} def snake_case__ ( a , a ) -> str: '''simple docstring''' if isinstance(a , a ): raise TypeError("""int() can't convert non-string w...
566
'''simple docstring''' from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging a__ = logging.get_logger(__name__) a__ = { '''huggingface/informer-tourism-monthly''': ( '''https://huggingface.co/huggingface/in...
566
1
# using dfs for finding eulerian path traversal def lowerCamelCase__ (_UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase=None): SCREAMING_SNAKE_CASE = (path or []) + [u] for v in graph[u]: if visited_edge[u][v] is False: SC...
73
def lowerCAmelCase ( UpperCAmelCase, UpperCAmelCase ) ->int: """simple docstring""" return abs(UpperCAmelCase ) if a == 0 else greatest_common_divisor(b % a, UpperCAmelCase ) def lowerCAmelCase ( UpperCAmelCase, ...
154
0
"""simple docstring""" import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class lowercase( tf.keras.optimiz...
716
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils impor...
28
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCAmelCase_ = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Mobi...
2
class a__ : def __init__( self : Tuple ): """simple docstring""" SCREAMING_SNAKE_CASE_ : str = 0 SCREAMING_SNAKE_CASE_ : Tuple = 0 SCREAMING_SNAKE_CASE_ : Union[str, Any] = {} def ...
216
0
"""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....
183
"""simple docstring""" 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 ...
183
1
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roberta import RobertaTok...
684
'''simple docstring''' from __future__ import annotations a__ : Optional[int] = list[tuple[int, int]] a__ : List[Any] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], ...
368
0
'''simple docstring''' class UpperCAmelCase_ : '''simple docstring''' def __init__( self , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase : List[str] = name ...
706
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def a ( SCREAMING_SNAKE_CASE_ : bool = True , *SCREAMING_SNAKE_CASE_ : List[str] , **SCREAMING_SNAKE_CASE_ : Tuple ...
643
0
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake A = numpy.array([0, 0]) A = numpy.array([0.5, 0.8_6_6_0_2_5_4]) A = numpy.array([1, 0]) A = [VECTOR_1, VECTOR_2, VECTOR_3, VECTOR_1] def a(low...
187
import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def UpperCAmelCase_ ( __UpperCamelCase = 8 ): SCREAMING_SNAKE_CASE__ =ascii_letters + digits + punctuation return "".join(secrets.choice(__UpperC...
151
0
import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCAmelCase = logging.get_logger(__name__) ...
720
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from t...
565
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase_ = {"""configuration_timm_backbone""": ["""TimmBackboneConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Opt...
411
'''simple docstring''' import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) fr...
133
0
"""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 # ...
261
"""simple docstring""" from typing import Dict, Optional import numpy as np import datasets __UpperCAmelCase =""" 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 c...
261
1
# 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 a_ : Tuple = TypeVar('T') class _snake_case ( Generic[T] ): def __init__( se...
73
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGenerationTesterMix...
324
0
from __future__ import annotations from typing import Any class lowerCAmelCase__: '''simple docstring''' def __init__( self , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase = 0 ) -> None: _SCREAMING_SNAKE_CASE , _SCRE...
718
from PIL import Image def lowerCamelCase__ (__lowerCamelCase ): _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE : List[str] = image.size _SCREAMING_SNAKE_CASE : Tuple = 0 _SCREAMING_SNAKE_CASE : Dict = image.load() f...
381
0
from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnProcessor fr...
475
"""simple docstring""" import inspect import unittest from transformers import ViTMSNConfig 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_configuration_common import Co...
473
0
"""simple docstring""" import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch lowerCAmelCase : Optional[Any] ...
533
"""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 lowerCAmelCase : List[str] = 4 lowerCAmelCase : List[str]...
533
1
"""simple docstring""" import os def a_ ( ): with open(os.path.dirname(_UpperCamelCase ) + """/p022_names.txt""" ) as file: __lowerCamelCase = str(file.readlines()[0] ) __lowerCamelCase = names.replace("""\"""", ""...
281
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position a : Dict = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('''3.7'''): raise ...
639
0
'''simple docstring''' import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class UpperCAmelCase_ ( __A ): """simple docstring"...
8
'''simple docstring''' from __future__ import annotations import math def lowercase_ ( __A : float , __A : int ) -> float: """simple docstring""" lowercase : str =u for i in range(1 , __A ): lowercase : Any =temp * ...
8
1
'''simple docstring''' from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class SCREAMIN...
685
'''simple docstring''' import argparse import os import torch from transformers.utils import WEIGHTS_NAME UpperCamelCase__ = ['small', 'medium', 'large'] UpperCamelCase__ = 'lm_head.decoder.weight' UpperCamelCase__ = 'lm_head.weight' def __SCREAMING_SNAKE_CASE ( _UpperCamelC...
620
0
"""simple docstring""" import cva import numpy as np class UpperCAmelCase_ : def __init__( self : int , __UpperCamelCase : float , __UpperCamelCase : int ) -> int: if k in (0.0_4, 0.0_6): _UpperCamelCase = k _UpperCamelC...
342
"""simple docstring""" import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow UpperCAmelCase = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ """text-cla...
342
1