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 argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def lowerCame...
46
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_to...
561
0
"""simple docstring""" from math import factorial def _SCREAMING_SNAKE_CASE ( __snake_case : int = 1_00 ): '''simple docstring''' return sum(int(__snake_case ) for x in str(factorial(__snake_case ) ) ) if __name__ == "__main__": print(solution(int(input...
134
"""simple docstring""" import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWaterma...
134
1
import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch impo...
101
'''simple docstring''' # Copyright 2022 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...
126
0
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 impo...
718
from math import asin, atan, cos, radians, sin, sqrt, tan _UpperCAmelCase = 6_378_137.0 _UpperCAmelCase = 6_356_752.314_245 _UpperCAmelCase = 637_8137 def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :float , SCREAMING_SNAKE_CASE :float , SCREAM...
240
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCamelCase__ : int = { """configurati...
614
'''simple docstring''' import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mo...
676
0
from __future__ import annotations from collections.abc import Sequence from typing import Literal def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : Union[str, Any] , SCREAMING_SNAKE_CASE__ : Optional[Any] ): __UpperCamelCase =list(snake_case_ ) __UpperC...
710
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): im...
682
0
"""simple docstring""" import requests __lowerCAmelCase : int = '''https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=''' def __lowerCAmelCase ( __UpperCamelCase : str ): '''simple docstring''' snake_case...
58
"""simple docstring""" # Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def __lowerCAmelCase ( __UpperCamelCase : int , __UpperCamelCase : str , __UpperCamelCase : Any ): '''simple docstring''' ...
58
1
'''simple docstring''' import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import GenerationTe...
47
'''simple docstring''' import os import numpy import onnx def _a ( lowerCAmelCase_ , lowerCAmelCase_ ): """simple docstring""" _snake_case : List[Any] = a.name _snake_case : List[Any] = b.name _snake_case : Tuple = ...
47
1
def A(__a: int ): lowerCAmelCase_ = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
122
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_available(): raise OptionalDependency...
122
1
'''simple docstring''' import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...u...
717
# 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 lowercase_ = TypeVar('''T''') class A__ ( Generic[T] ): def _...
336
0
'''simple docstring''' import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModel...
28
"""simple docstring""" import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serializati...
575
0
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def lowercase_( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' if "img_encoder.pos_embed" in name: ...
721
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import Fe...
231
0
"""simple docstring""" 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 imp...
522
"""simple docstring""" from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time lowercase__ :List[Any] = Lock() def lowerCamelCase_ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase...
522
1
def _snake_case (__lowercase): if p < 2: raise ValueError('p should not be less than 2!') elif p == 2: return True UpperCamelCase_ = 4 UpperCamelCase_ = (1 << p) - 1 for _ in range(p - 2): UpperCamelCase_ = ((s * s) - ...
618
def _snake_case (__lowercase , __lowercase , __lowercase): return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(__lowercase)) def _snake_case (__lowercase , __lowercase , __lowercase ...
618
1
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils im...
393
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def UpperCAmelCase ( UpperCAmelCase )-> Optional[int]: '''simple docstring''' SCREAMING_SNA...
393
1
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=_UpperCAmelCase) class lowerCamelCase__ ( _UpperCAmelCase): """simple docstring""" _A = field(default='ques...
704
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, ...
484
0
"""simple docstring""" import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging lowerCAmelCase__ =logging.get_logger(__name__) lowerCAmelCase__ ={"vocab_file": "v...
482
"""simple docstring""" 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 PegasusTok...
482
1
def lowerCamelCase__ ( _A ): '''simple docstring''' snake_case_ = generate_pascal_triangle(_A ) for row_idx in range(_A ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=" " ) # Print row values for...
139
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_verbosity_info() def lowerC...
139
1
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTokenizerFast, ) def...
175
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_...
215
0
"""simple docstring""" import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import ...
721
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping __A : str = tuple[int, int] class lowerCAmelCase__ : """simple docstring""" def __init__( self : int , lowercase__ : set[int] , lowercase...
281
0
import numpy as np from PIL import Image def _lowerCamelCase ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ) -> np.ndarray: '''simple docstring''' UpperCAmelCase__ : Dict = np.array(__lowerCamelCase ) if arr.s...
79
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax.struct.dataclass ...
590
0
import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig ...
702
from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tenso...
177
0
# 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 app...
411
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_verbosity_info() def lowerCamelCase_ (...
411
1
'''simple docstring''' def __snake_case( _lowerCAmelCase ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError("""The given input must be positive""" ) # get the generated string sequence snake_case__ : str ...
301
'''simple docstring''' def __snake_case( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ) -> bool: return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(_lowerCAmelCase ) ) def __snake_case( _lowerCAmelCase...
301
1
import os import sys import unittest lowerCamelCase__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_...
612
"""simple docstring""" def a_ ( lowercase__ :str, lowercase__ :int ): return [sentence[i : i + ngram_size] for i in range(len(lowercase__ ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
281
0
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 ConfigTes...
643
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter __UpperCAmelCase : List[An...
643
1
'''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_torch_available(): impor...
131
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def A_ ( __lowercase ): # This defines a "chinese character" as anything in the CJK Unicode block: # https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Unic...
357
0
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import...
209
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 ( enable_full_determinism, ...
209
1
"""simple docstring""" import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class UpperCamelCase__ (...
545
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def A ( __snake_case: Tuple ) -> Optional[Any]: """simple docstring""" if ( ...
545
1
"""simple docstring""" import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, ...
720
"""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 f...
468
0
import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput __UpperCAmelCase = 'scheduler_config.json' class __a ( __UpperCamelCase ):...
600
'''simple docstring''' import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def A__ ( UpperCAmelCase_ ): if "model" in orig_key: _UpperCamelCase : List[Any] = orig_key.replace('model.' , '' ) if "norm1" in orig_key: ...
195
0
from __future__ import annotations def __lowerCamelCase ( _lowercase ) -> bool: return len(set(_lowercase ) ) == len(_lowercase ) if __name__ == "__main__": import doctest doctest.testmod()
170
def __lowerCamelCase ( _lowercase , _lowercase ) -> tuple[float, float]: # Check if the input is valid if not len(_lowercase ) == len(_lowercase ) == 3: raise ValueError('Please enter a valid equation.' ) if equationa[0] == equationa[1] == equationa[0] == equationa[1] =...
170
1
'''simple docstring''' import json import os import torch from diffusers import UNetaDModel os.makedirs('''hub/hopper-medium-v2/unet/hor32''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/unet/hor128''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/value_function''', exist_ok=Tr...
69
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging UpperCamelCase = logging.get_logger(__name__) def lowerCamelCase_ ( ...
520
0
'''simple docstring''' def __lowerCAmelCase ( a_ , a_ ) -> list: '''simple docstring''' SCREAMING_SNAKE_CASE : Union[str, Any] = word.split() def justify(a_ , a_ , a_ ) -> str: SCREAMING_...
708
'''simple docstring''' from __future__ import annotations import unittest from transformers import LEDConfig, 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...
179
0
'''simple docstring''' _lowercase = 65521 def A (__lowerCamelCase :Optional[Any] ): _lowerCAmelCase = 1 _lowerCAmelCase = 0 for plain_chr in plain_text: _lowerCAmelCase = (a + ord(a_ )) % MOD_ADLER _lowerCAmelCase = ...
5
'''simple docstring''' import json import os import torch from diffusers import UNetaDModel os.makedirs("""hub/hopper-medium-v2/unet/hor32""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/unet/hor128""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/value_function""", exist_ok=True...
251
0
from __future__ import annotations def __snake_case ( _UpperCamelCase ) -> list[int]: _a = [True] * limit _a = False _a = False _a = True for i in range(3 , int(limit**0.5 + 1 ) , 2 ): _a = i * 2...
346
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def __snake_case ( _UpperCamelCase ) -> int: _a = prime_factors(_UpperCamelCase ) if is_square_free(_UpperCamelCase ): return -1 if len(_UpperCamelCase ) % 2 else 1 return 0 ...
346
1
'''simple docstring''' def __a(SCREAMING_SNAKE_CASE_ : int = 1 , SCREAMING_SNAKE_CASE_ : int = 1000 ): '''simple docstring''' _lowerCAmelCase = 1 _lowerCAmelCase = 0 for divide_by_number in range(SCREAMING_SNAKE_CASE_ , digit...
18
"""simple docstring""" def __snake_case ( __A : list , __A : int , __A : int = 0 , __A : int = 0 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE : Any = right or len(__A ) - 1 if left ...
265
0
'''simple docstring''' from __future__ import annotations def _lowercase ( lowerCamelCase__ : dict, lowerCamelCase__ : str ): _a , _a = set(lowerCamelCase__ ), [start] while stack: _a = stack.pop() explored.add(lowerCamelCase__ ...
691
'''simple docstring''' def _lowercase ( lowerCamelCase__ : int, lowerCamelCase__ : int ): return number | (1 << position) def _lowercase ( lowerCamelCase__ : int, lowerCamelCase__ : int ): return number & ~(1 << position) def _lowercase ( lowerCamelCase_...
691
1
"""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 UpperCAmelCase__ : str = 4 UpperCAmelCase__ : Dict...
223
"""simple docstring""" import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor UpperCAmelCase__ : List[str] = logging.get_logger(__name__) class lowerCAmelCase_ (a__ ): """simple docstring""" ...
223
1
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common import S...
720
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase : Optional[Any] = { "configuration_swiftformer": [ "SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwiftFormerConf...
30
0
"""simple docstring""" from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone import...
29
'''simple docstring''' import math from collections.abc import Iterator from itertools import takewhile def _lowerCAmelCase ( lowerCamelCase_ : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number %...
502
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : int = logging.get_logger(__name__) lowerCamelCase__ : List[Any] = { "google/canine-s": "https://huggingface.co/google/canine-s/resolve/main/config....
18
"""simple docstring""" import math class lowercase__: '''simple docstring''' def __init__( self :Union[str, Any] , lowerCamelCase_ :List[str]=0 ) -> List[Any]: # a graph with Node 0,1,...,N-1 '''simple docstring''' SCREAMING_SNAKE_CASE : Tuple = n...
18
1
"""simple docstring""" import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __lowerCAmelCase : str = lo...
58
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.convert_switch_...
631
0
'''simple docstring''' import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class lowerCamelCase_ ( _A ): '''simple docstring''' a__ = "M-CLIP" def __init__( self : Dict , __lowerCamelCase :...
715
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=_A ) class lowerCamelCase_ ( _A ): '''simple docstring''' # `task` is not a ClassVar since...
17
0
"""simple docstring""" import warnings from ..trainer import Trainer from ..utils import logging __UpperCAmelCase =logging.get_logger(__name__) class lowerCAmelCase__ ( UpperCAmelCase_ ): def __init__( self , UpperCamelCase__=None , **UpperCamelCase__ ): '''simple doc...
337
"""simple docstring""" __UpperCAmelCase ="""0.18.2""" from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, ...
337
1
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class snake_case ( __UpperCAmelCase ): '''simple docstring''' _A : ...
374
"""simple docstring""" # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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/l...
374
1
"""simple docstring""" def lowerCamelCase_ ( __lowerCAmelCase ) -> Tuple: '''simple docstring''' return "".join(chr(ord(__lowerCAmelCase ) - 32 ) if "a" <= char <= "z" else char for char in word ) if __name__ == "__main__": from doctest import testmod te...
530
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() __a : Union[str, Any] = logging.get_logger(__name__) def UpperCAmelCase ( lowercase ): """simple docst...
534
0
'''simple docstring''' 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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image...
418
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase : Tuple = {"""configuration_fnet""": ["""FNET_PRET...
418
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : Any = logging.get_logger(__name__) lowercase__ : Optional[int] = { "asapp/sew-tiny-100k": "https://huggingface.co/asapp/sew-tiny-1...
376
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, ...
376
1
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def UpperCAmelCase_( a__ ): """simple docstring""" if not is_accelerate_available(): return method SCREAMING_SNAKE_CASE : ...
707
def UpperCAmelCase_( a__ ): """simple docstring""" if collection == []: return [] # get some information about the collection SCREAMING_SNAKE_CASE : List[Any] = len(a__ ) SCREAMING_SNAKE_CASE : int = max(a__ ) ...
333
0
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformer...
339
"""simple docstring""" import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import Accelerat...
506
0
import argparse import json 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...
709
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, 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...
224
0
from ..utils import DummyObject, requires_backends class a_ ( metaclass=a ): A__ : Any = ['transformers', 'torch', 'note_seq'] def __init__( self : Union[str, Any] , *UpperCAmelCase__ : Dict , **UpperCAmelCase__ : Optional[Any] ): ...
598
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=a ) class a_ ( a ): # `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON ser...
598
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : List[Any] = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""], ...
700
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils...
308
0
'''simple docstring''' import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipelin...
94
"""simple docstring""" import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from tra...
564
0
"""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 lowerCAmelCase_: Dict = logging.get_logger(__name__) lowerCAmelCase_: Di...
668
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import ...
668
1
from typing import List from .keymap import KEYMAP, get_character def snake_case (__lowercase ) -> Dict: '''simple docstring''' def decorator(__lowercase ): _snake_case : str = getattr(__lowercase , "handle_key" , [] ) handle += [key] ...
670
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Optional[int] = logging.get_logger(__name__) UpperCAmelCase_ : List[str] = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google...
120
0
"""simple docstring""" def lowerCAmelCase_( SCREAMING_SNAKE_CASE = 50_00_00_00 ) -> int: """simple docstring""" UpperCamelCase__ = set() UpperCamelCase__ = int((limit - 24) ** (1 / 2) ) UpperCamelCase__ = set(range(3 , prime_square_limit + 1 ,...
715
"""simple docstring""" from copy import deepcopy class __lowerCamelCase : def __init__( self , snake_case_ = None , snake_case_ = None ) -> None: if arr is None and size is not None: UpperCamelCase__ = size UpperCam...
20
0
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor _lowercase : Union[str, Any] =logging.get_logger(__name__) class snake_case__ (A__ ): """simple docstring""" def __init__( self , *...
136
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowercase : Optional[int] ={ "configuration_bloom": ["BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP", "BloomConfig", "BloomOnnxConfig"], } try: i...
136
1
'''simple docstring''' from __future__ import annotations class _A : '''simple docstring''' def __init__( self : Optional[Any] , lowerCamelCase : str , lowerCamelCase : str )-> List[str]: snake_case__ , snake_case__ : Op...
172
'''simple docstring''' 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 lowerCAmelCase__ = 'src/diffusers' # Matches is_xxx_available() lowerCAmelCase__ = re.c...
172
1
'''simple docstring''' import math import qiskit def _A ( _lowerCAmelCase = 1 , _lowerCAmelCase = 1 , _lowerCAmelCase = 1 ): """simple docstring""" if ( isinstance(a_ , a_ ) or isinstance(a_ , a_ ) or isinstance(a_ , a_ ) ...
474
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchma...
251
0
import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_utils import OnnxRuntimeMode...
707
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass __snake_case : Optional[int] =(3, 9, -1_1, 0, 7, 5, 1, -1) __snake_case : str =(4, 6, 2, 0, 8, 1_0, 3, -2) @dataclass class lowerCamelCase__ : '''simpl...
90
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""], """configuration...
77
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_a...
372
0
'''simple docstring''' from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def _lowerCAmelCase ( _lowerCAmelCase , _lowerCAmelCase )-> Optional[int]: __UpperCAmelCas...
715
'''simple docstring''' import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex _A: int = logging.getLogger(__name__) class UpperCAmelCase : def __init__( self ...
617
0
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def snake_case_ ( ) -> Any: import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname...
397
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __a : List[str] = { '''configuration_maskformer''': ['''MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MaskFormerConfig'''], ''...
397
1
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 __lowerCamelCase ( __snake_case ): def __init__( self ,...
161
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''sayakpaul/vit-msn-base''': '''https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json''', # See all ViT MSN models ...
161
1
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, Auto...
71
from math import factorial class _a : """simple docstring""" def __init__( self , _snake_case , _snake_case ): _UpperCAmelCase =real if isinstance(_snake_case , _snake_case ): _UpperCAmelCase =[1] * rank else: ...
408
0
"""simple docstring""" from typing import Any class lowercase_ : '''simple docstring''' def __init__( self : Union[str, Any] , _UpperCAmelCase : Any ): _A = data _A = None class lowercase_ : '''simple docstring''' def __ini...
505
"""simple docstring""" import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import Nested...
505
1
'''simple docstring''' import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm...
597
from __future__ import annotations from typing import Any class UpperCAmelCase__ : '''simple docstring''' def __init__( self : Dict , UpperCamelCase : int = 6 ): """simple docstring""" _lowercase : Node | None ...
322
0
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, BlipImageProcessor, Blip...
522
from math import factorial __a : dict[str, int] = {str(digit): factorial(digit) for digit in range(1_0)} def UpperCAmelCase ( lowercase ): """simple docstring""" if not isinstance(lowercase , lowercase ): raise TypeError('''Parameter n...
522
1
'''simple docstring''' import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import hugg...
44
import os import time import numpy as np import onnxruntime as ort __snake_case :Any ='1' __snake_case :List[str] ='0' __snake_case :Union[str, Any] ='1' __snake_case :Optional[Any] =ort.SessionOptions() __snake_case :List[str] =ort.GraphOptimizat...
106
0
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class A_ ( snake_case_ ): UpperCAmelCase__...
700
"""simple docstring""" 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 Att...
468
0
"""simple docstring""" import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def a ( __snake_case : Optional[Any], __snake_case : Union[str, Any], __sna...
608
"""simple docstring""" import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class _snake_case ( A__ ): '''simple docstring''' UpperCamelCase__ =(CMStochasticIterativeScheduler,) UpperCamelCase__ =10 ...
608
1
'''simple docstring''' import string def UpperCamelCase__ ( a__ ): '''simple docstring''' _lowerCAmelCase ='' for i in sequence: _lowerCAmelCase =ord(lowerCAmelCase__ ) if 6_5 <= extract <= 9_0: output += chr(...
708
'''simple docstring''' import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is...
58
0
"""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 _lowerCAmelCase : List[Any] = logging.get_logger(__name__) _lowerCAm...
289
"""simple docstring""" import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transform...
289
1
import os import string import sys lowercase__ : List[Any] = 1 << 8 lowercase__ : int = { 'tab': ord("\t"), 'newline': ord("\r"), 'esc': 2_7, 'up': 6_5 + ARROW_KEY_FLAG, 'down': 6_6 + ARROW_KEY_FLAG, 'right': 6_7 + ARROW_KEY_FLAG, 'left': 6_8 +...
711
from collections import Counter from timeit import timeit def A_ ( snake_case : str = "" , ) -> bool: '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def A_ ( snake_case : str ...
451
0
# Copyright 2022 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...
557
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase : Tuple = { 'configuration_luke': ['LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LukeConfig'], 'tokenization_luke': ['LukeTokenizer'], } try: if not is_torch_av...
557
1
import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small/resolve/main/compression_...
707
import argparse import struct import unittest class __lowerCAmelCase : """simple docstring""" def __init__( self : List[str] , _snake_case : bytes ): """simple docstring""" A__ = data # Initialize hash values ...
52
0
# 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.0 # # Unless required by applic...
590
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor UpperCamelCase = logging.get_logger(__name__) class _lowerCamelCase ( UpperCamelCase ): """simple docstring""" def __init__( self , *_SCRE...
590
1
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Union[str, Any] ...
717
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) def snake_case ( lowerCamelCase ...
53
0
# Copyright 2023 The HuggingFace Inc. 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 b...
100
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class _SCREAMING_SNAKE_CASE : lowerCamelCase_ = 42 lowerCamelCase_ = 42 class _SCREAMING_SNAKE_CASE : def __...
256
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __snake_case : List[Any] = { "configuration_roberta": [...
702
'''simple docstring''' def _lowercase ( lowerCamelCase__ : int, lowerCamelCase__ : int ): return number | (1 << position) def _lowercase ( lowerCamelCase__ : int, lowerCamelCase__ : int ): return number & ~(1 << position) def _lowercase ( lowerCamelCase_...
691
0
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import loggi...
604
'''simple docstring''' import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast _SCREAMING_SNAKE_CASE : Optional[Any] = datasets.utils.logging.get_logger(__name...
400
0
"""simple docstring""" from pathlib import Path import fire def lowerCamelCase_ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ ) ->int: """simple docstring""" __UpperCAmelCase : Dict = Path(UpperCAmelCase_ ) __Upp...
374
"""simple docstring""" def lowerCamelCase_ ( UpperCAmelCase_ , UpperCAmelCase_ ) ->Tuple: """simple docstring""" return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def lowerCamelCase_ ( UpperCAmelCase_ , UpperCAmelCa...
374
1
"""simple docstring""" def __a ( A ) -> Any: '''simple docstring''' A__ = [] A__ = set({"(", "[", "{"} ) A__ = set({")", "]", "}"} ) A__ = {"{": "}", "[": "]", "(": ")"} for i in range(len(A ) ): if s...
337
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCAmelCase ={ """configuration_rembert""": ["""REMBER...
337
1
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_stab...
429
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...
429
1
"""simple docstring""" import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_...
580
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_dimen...
61
0
'''simple docstring''' import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class _snake_case (tf.keras.layers.Layer): def __...
323
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser ...
323
1
"""simple docstring""" _SCREAMING_SNAKE_CASE : List[str] = {str(digit): digit**5 for digit in range(10)} def lowerCamelCase__ ( _lowerCamelCase : int ) -> int: return sum(DIGITS_FIFTH_POWER[digit] for digit in str(_lowerCamelCase ) ...
549
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase : list[list[int | float]] ) -> int: lowerCamelCase_ = len(_lowerCamelCase ) lowerCamelCase_ = len(matrix[0] ) lowerCamelCase_ = min(_lowerCamelCase , _lowerCa...
549
1
def A_( ): return [list(range(1000 - i , -1000 - i , -1 ) ) for i in range(1000 )] UpperCamelCase__ = generate_large_matrix() UpperCamelCase__ = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]], [[3, 2], [1, 0]], [[7, 7, 6]], ...
712
import os 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 UpperCamelCase__ : List[str] = logging.get_logger(__name__) UpperCamel...
486
0
'''simple docstring''' import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ,...
42
import copy import random from transformers import CLIPTokenizer class A__ ( __SCREAMING_SNAKE_CASE): def __init__( self , *__magic_name__ , **__magic_name__ ): super().__init__(*__magic_name__ , **__magic_name__ ) lowerCamelCase : Dict ...
681
0
"""simple docstring""" from maths.prime_check import is_prime def lowercase_ ( _snake_case ): if not isinstance(_snake_case ,_snake_case ): SCREAMING_SNAKE_CASE__ : str = f'''Input value of [number={number}] must be an integer''' raise TypeErro...
545
"""simple docstring""" from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ....
545
1
def UpperCamelCase ( snake_case__ : List[str] , snake_case__ : Any ) -> Union[str, Any]: UpperCamelCase : int = [1] for i in range(2 , snake_case__ ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k...
40
"""simple docstring""" UpperCAmelCase : int = [ (1000, "M"), (900, "CM"), (500, "D"), (400, "CD"), (100, "C"), (90, "XC"), (50, "L"), (40, "XL"), (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"), ] def _SCREAMING_SNAKE_C...
567
0
import warnings 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 a_( lowercase__ ): """simple docstring...
707
import os import re import shutil import sys import tempfile import unittest import black __UpperCAmelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa: E402 # This is the referen...
259
0
def a ( a ) ->bool: '''simple docstring''' if p < 2: raise ValueError('''p should not be less than 2!''' ) elif p == 2: return True SCREAMING_SNAKE_CASE = 4 SCREAMING_SNAKE_CASE = (1 << p) - 1 for _ in range(p - 2 ): SCREAMING_SNAKE_CASE ...
201
import json import os import torch from diffusers import UNetaDModel os.makedirs('hub/hopper-medium-v2/unet/hor32', exist_ok=True) os.makedirs('hub/hopper-medium-v2/unet/hor128', exist_ok=True) os.makedirs('hub/hopper-medium-v2/value_function', exist_ok=True) def a ( a ) ->List[Any]: '''simpl...
201
1
from numpy import exp, pi, sqrt def UpperCAmelCase_ ( __a : Dict , __a : int = 0.0 , __a : Dict = 1.0 ): '''simple docstring''' return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if __name__ == "__main__": import doctest doc...
716
"""simple docstring""" def UpperCAmelCase_ ( __a : int = 10_00 ): '''simple docstring''' _lowerCamelCase , _lowerCamelCase : Dict = 1, 1 _lowerCamelCase : Optional[Any] = 2 while True: _lowerCamelCase : str =...
349
0
class A : def __init__( self , lowercase_ ) -> None: '''simple docstring''' _snake_case : str = set_counts _snake_case : Union[str, Any] = max(lowercase_ ) _snake_case : List[Any] ...
326
import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_available if is_vision...
81
0
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def snake_case ( _a: Dict , _a: Optional[Any] , _a: str )-> str: '''simple ...
707
"""simple docstring""" def snake_case ( _a: List[Any] , _a: Any , _a: str , _a: List[Any] )-> List[Any]: '''simple docstring''' lowerCamelCase__ = [False] * len(_a ) lowerCamelCase__ = [] queue.append(_a ...
659
0
'''simple docstring''' import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING _SCREAMING_SNAKE_CASE = { "facebook/mask2former-swin-small-coco-instance": ( "https://huggingfac...
18
"""simple docstring""" def UpperCAmelCase ( A : list[int] , A : list[int] ): '''simple docstring''' if not len(A ) == len(A ) == 3: raise ValueError('Please enter a valid equation.' ) if equationa[0] == equationa[1] == equationa...
573
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ : Union[str, Any] = logging.get_logger(__name__) lowercase__ : Union[str, Any] ...
43
'''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 lowerCamelCase ( lowerCamelCase , unittest....
43
1