id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
6,008 | import os
from pyUltroid import ULTConfig
import qrcode
from PIL import Image
from telethon.tl.types import MessageMediaDocument as doc
from . import check_filename, get_string, ultroid_bot, ultroid_cmd
import qrcode
async def qrwater(e):
msg = e.pattern_match.group(1).strip()
r = await e.get_reply_message()
... | null |
6,009 | import os
from pyUltroid import ULTConfig
try:
import cv2
except ImportError:
cv2 = None
import qrcode
from PIL import Image
from telethon.tl.types import MessageMediaDocument as doc
from . import check_filename, get_string, ultroid_bot, ultroid_cmd
async def decod(e):
r = await e.get_reply_message()
i... | null |
6,010 | from telethon.errors.rpcerrorlist import (
BotInlineDisabledError,
BotMethodInvalidError,
BotResponseTimeoutError,
)
from telethon.tl.custom import Button
from pyUltroid.dB._core import HELP, LIST
from pyUltroid.fns.tools import cmd_regex_replace
from . import HNDLR, LOGS, OWNER_NAME, asst, get_string, inli... | null |
6,011 | from . import get_help
import os
import random
from telethon.utils import get_display_name
from urllib.parse import urlencode
from . import Carbon, ultroid_cmd, get_string, inline_mention
from secrets import token_hex
if os.path.exists(_colorspath):
with open(_colorspath, "r") as f:
all_col = f.read().split... | null |
6,012 | from . import get_help
import os
import random
from telethon.utils import get_display_name
from urllib.parse import urlencode
from . import Carbon, ultroid_cmd, get_string, inline_mention
from secrets import token_hex
if os.path.exists(_colorspath):
with open(_colorspath, "r") as f:
all_col = f.read().split... | null |
6,013 | from . import get_help
import os
import random
from telethon.utils import get_display_name
from urllib.parse import urlencode
from . import Carbon, ultroid_cmd, get_string, inline_mention
from secrets import token_hex
if os.path.exists(_colorspath):
with open(_colorspath, "r") as f:
all_col = f.read().split... | null |
6,014 | import os
from . import LOGS, con
try:
import cv2
except ImportError:
LOGS.error(f"{__file__}: OpenCv not Installed.")
import numpy as np
from telegraph import upload_file as upf
from telethon.errors.rpcerrorlist import (
ChatSendMediaForbiddenError,
MessageDeleteForbiddenError,
)
from . import (
Re... | null |
6,015 | import os
from . import LOGS, con
import numpy as np
from telegraph import upload_file as upf
from telethon.errors.rpcerrorlist import (
ChatSendMediaForbiddenError,
MessageDeleteForbiddenError,
)
from . import (
Redis,
async_searcher,
download_file,
get_string,
requests,
udB,
ultroi... | null |
6,016 | import os
from . import LOGS, con
import numpy as np
from telegraph import upload_file as upf
from telethon.errors.rpcerrorlist import (
ChatSendMediaForbiddenError,
MessageDeleteForbiddenError,
)
from . import (
Redis,
async_searcher,
download_file,
get_string,
requests,
udB,
ultroi... | null |
6,017 | import os
from . import LOGS, con
try:
import cv2
except ImportError:
LOGS.error(f"{__file__}: OpenCv not Installed.")
import numpy as np
from telegraph import upload_file as upf
from telethon.errors.rpcerrorlist import (
ChatSendMediaForbiddenError,
MessageDeleteForbiddenError,
)
from . import (
Re... | null |
6,018 | import os
from . import LOGS, con
try:
import cv2
except ImportError:
LOGS.error(f"{__file__}: OpenCv not Installed.")
import numpy as np
from telegraph import upload_file as upf
from telethon.errors.rpcerrorlist import (
ChatSendMediaForbiddenError,
MessageDeleteForbiddenError,
)
from . import (
Re... | null |
6,019 | from . import get_help
import string
from . import eod, ultroid_cmd
Fonts = {
"small caps": "ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘϙʀsᴛᴜᴠᴡxʏᴢABCDEFGHIJKLMNOPQRSTUVWXYZ",
"monospace": "𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉",
"double stroke": "𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛�... | null |
6,020 | from . import get_help
from pyUltroid.dB.blacklist_db import (
add_blacklist,
get_blacklist,
list_blacklist,
rem_blacklist,
)
from . import events, get_string, udB, ultroid_bot, ultroid_cmd
async def blacklist(e):
def add_blacklist(chat, word):
async def af(e):
wrd = e.pattern_match.group(1).strip... | null |
6,021 | from . import get_help
from pyUltroid.dB.blacklist_db import (
add_blacklist,
get_blacklist,
list_blacklist,
rem_blacklist,
)
from . import events, get_string, udB, ultroid_bot, ultroid_cmd
def rem_blacklist(chat, word):
ok = get_stuff()
if ok.get(chat) and word in ok[chat]:
ok[chat].re... | null |
6,022 | from . import get_help
from pyUltroid.dB.blacklist_db import (
add_blacklist,
get_blacklist,
list_blacklist,
rem_blacklist,
)
from . import events, get_string, udB, ultroid_bot, ultroid_cmd
def list_blacklist(chat):
ok = get_stuff()
if ok.get(chat):
txt = "".join(f"👉`{z}`\n" for z in o... | null |
6,023 | import glob
import io
import os
import random
from os import remove
from telethon.errors import PeerIdInvalidError, YouBlockedUserError
from telethon.tl.functions.messages import UploadMediaRequest
from telethon.tl.types import (
DocumentAttributeFilename,
DocumentAttributeSticker,
InputPeerSelf,
)
from tel... | null |
6,024 | import glob
import io
import os
import random
from os import remove
try:
import cv2
except ImportError:
cv2 = None
from telethon.errors import PeerIdInvalidError, YouBlockedUserError
from telethon.tl.functions.messages import UploadMediaRequest
from telethon.tl.types import (
DocumentAttributeFilename,
... | null |
6,025 | import glob
import io
import os
import random
from os import remove
from telethon.errors import PeerIdInvalidError, YouBlockedUserError
from telethon.tl.functions.messages import UploadMediaRequest
from telethon.tl.types import (
DocumentAttributeFilename,
DocumentAttributeSticker,
InputPeerSelf,
)
from tel... | null |
6,026 | import glob
import io
import os
import random
from os import remove
from telethon.errors import PeerIdInvalidError, YouBlockedUserError
from telethon.tl.functions.messages import UploadMediaRequest
from telethon.tl.types import (
DocumentAttributeFilename,
DocumentAttributeSticker,
InputPeerSelf,
)
from tel... | null |
6,027 | import glob
import io
import os
import random
from os import remove
try:
import cv2
except ImportError:
cv2 = None
from telethon.errors import PeerIdInvalidError, YouBlockedUserError
from telethon.tl.functions.messages import UploadMediaRequest
from telethon.tl.types import (
DocumentAttributeFilename,
... | null |
6,028 | from telethon.tl.types import InputMediaPoll, Poll, PollAnswer
from . import get_string, ultroid_cmd
async def uri_poll(e):
if not e.client._bot and e.is_private:
return await e.eor("`Use this in Group/Channel.`", time=15)
match = e.pattern_match.group(1).strip()
if not match:
return await ... | null |
6,029 | import time
import numpy as np
import sys
import random
import os
import warnings
import torch
from torch.utils.tensorboard import SummaryWriter
import torch.distributed as dist
import torch.multiprocessing as mp
import torch.utils.data.distributed
from tqdm import tqdm
from data_process.kitti_dataloader import create_... | null |
6,030 | import os
import argparse
import torch
from easydict import EasyDict as edict
def parse_train_configs():
parser = argparse.ArgumentParser(description='The Implementation of Complex YOLOv4')
parser.add_argument('--seed', type=int, default=2020,
help='re-produce the results with seed rand... | null |
6,031 | import math
import sys
import cv2
import numpy as np
import config.kitti_config as cnf
def removePoints(PointCloud, BoundaryCond):
# Boundary condition
minX = BoundaryCond['minX']
maxX = BoundaryCond['maxX']
minY = BoundaryCond['minY']
maxY = BoundaryCond['maxY']
minZ = BoundaryCond['minZ']
... | null |
6,032 | import math
import sys
import cv2
import numpy as np
import config.kitti_config as cnf
def makeBVFeature(PointCloud_, Discretization, bc):
Height = cnf.BEV_HEIGHT + 1
Width = cnf.BEV_WIDTH + 1
# Discretize Feature Map
PointCloud = np.copy(PointCloud_)
PointCloud[:, 0] = np.int_(np.floor(PointCloud... | null |
6,033 | import sys
import torch
from torch.utils.data import DataLoader
from data_process.kitti_dataset import KittiDataset
from data_process.transformation import Compose, OneOf, Random_Rotation, Random_Scaling, Horizontal_Flip, Cutout
class KittiDataset(Dataset):
def __init__(self, dataset_dir, mode='train', lidar_trans... | Create dataloader for testing phase |
6,034 | import sys
import math
import numpy as np
import torch
from config import kitti_config as cnf
def camera_to_lidar_point(points):
# (N, 3) -> (N, 3)
N = points.shape[0]
points = np.hstack([points, np.ones((N, 1))]).T # (N,4) -> (4,N)
points = np.matmul(cnf.R0_inv, points)
points = np.matmul(cnf.Tr... | null |
6,035 | import sys
import math
import numpy as np
import torch
from config import kitti_config as cnf
def center_to_corner_box3d(boxes_center, coordinate='lidar'):
# (N, 7) -> (N, 8, 3)
N = boxes_center.shape[0]
ret = np.zeros((N, 8, 3), dtype=np.float32)
if coordinate == 'camera':
boxes_center = camera... | null |
6,036 | import sys
import math
import numpy as np
import torch
from config import kitti_config as cnf
def center_to_corner_box3d(boxes_center, coordinate='lidar'):
# (N, 7) -> (N, 8, 3)
N = boxes_center.shape[0]
ret = np.zeros((N, 8, 3), dtype=np.float32)
if coordinate == 'camera':
boxes_center = camera... | null |
6,037 | from __future__ import print_function
import numpy as np
import cv2
def rotx(t):
# 3D Rotation about the x-axis.
c = np.cos(t)
s = np.sin(t)
return np.array([[1, 0, 0],
[0, c, -s],
[0, s, c]]) | null |
6,038 | from __future__ import print_function
import numpy as np
import cv2
def rotz(t):
# Rotation about the z-axis.
c = np.cos(t)
s = np.sin(t)
return np.array([[c, -s, 0],
[s, c, 0],
[0, 0, 1]]) | null |
6,039 | from __future__ import print_function
import numpy as np
import cv2
The provided code snippet includes necessary dependencies for implementing the `transform_from_rot_trans` function. Write a Python function `def transform_from_rot_trans(R, t)` to solve the following problem:
Transforation matrix from rotation matrix ... | Transforation matrix from rotation matrix and translation vector. |
6,040 | from __future__ import print_function
import numpy as np
import cv2
The provided code snippet includes necessary dependencies for implementing the `inverse_rigid_trans` function. Write a Python function `def inverse_rigid_trans(Tr)` to solve the following problem:
Inverse a rigid body transform matrix (3x4 as [R|t]) [... | Inverse a rigid body transform matrix (3x4 as [R|t]) [R'|-R't; 0|1] |
6,041 | from __future__ import print_function
import numpy as np
import cv2
class Object3d(object):
''' 3d object label '''
def __init__(self, label_file_line):
data = label_file_line.split(' ')
data[1:] = [float(x) for x in data[1:]]
# extract label, truncation, occlusion
self.type = da... | null |
6,042 | from __future__ import print_function
import numpy as np
import cv2
def load_image(img_filename):
return cv2.imread(img_filename) | null |
6,043 | from __future__ import print_function
import numpy as np
import cv2
def load_velo_scan(velo_filename):
scan = np.fromfile(velo_filename, dtype=np.float32)
scan = scan.reshape((-1, 4))
return scan | null |
6,044 | import sys
import torch
from utils.torch_utils import convert2cpu
def parse_cfg(cfgfile):
blocks = []
fp = open(cfgfile, 'r')
block = None
line = fp.readline()
while line != '':
line = line.rstrip()
if line == '' or line[0] == '#':
line = fp.readline()
contin... | null |
6,045 | import sys
import torch
sys.path.append('../')
from utils.torch_utils import convert2cpu
def print_cfg(blocks):
print('layer filters size input output')
prev_width = 416
prev_height = 416
prev_filters = 3
out_filters = []
out_widths = []
out_heights = []
... | null |
6,046 | import sys
import torch
from utils.torch_utils import convert2cpu
def load_conv(buf, start, conv_model):
num_w = conv_model.weight.numel()
num_b = conv_model.bias.numel()
conv_model.bias.data.copy_(torch.from_numpy(buf[start:start + num_b]))
start = start + num_b
conv_model.weight.data.copy_(torch.... | null |
6,047 | import sys
import torch
from utils.torch_utils import convert2cpu
def convert2cpu(gpu_matrix):
return torch.FloatTensor(gpu_matrix.size()).copy_(gpu_matrix)
def save_conv(fp, conv_model):
if conv_model.bias.is_cuda:
convert2cpu(conv_model.bias.data).numpy().tofile(fp)
convert2cpu(conv_model.we... | null |
6,048 | import sys
import torch
from utils.torch_utils import convert2cpu
def load_conv_bn(buf, start, conv_model, bn_model):
num_w = conv_model.weight.numel()
num_b = bn_model.bias.numel()
bn_model.bias.data.copy_(torch.from_numpy(buf[start:start + num_b]))
start = start + num_b
bn_model.weight.data.copy_... | null |
6,049 | import sys
import torch
from utils.torch_utils import convert2cpu
def convert2cpu(gpu_matrix):
return torch.FloatTensor(gpu_matrix.size()).copy_(gpu_matrix)
def save_conv_bn(fp, conv_model, bn_model):
if bn_model.bias.is_cuda:
convert2cpu(bn_model.bias.data).numpy().tofile(fp)
convert2cpu(bn_m... | null |
6,050 | import sys
import torch
from utils.torch_utils import convert2cpu
def load_fc(buf, start, fc_model):
num_w = fc_model.weight.numel()
num_b = fc_model.bias.numel()
fc_model.bias.data.copy_(torch.from_numpy(buf[start:start + num_b]))
start = start + num_b
fc_model.weight.data.copy_(torch.from_numpy(b... | null |
6,051 | import sys
import torch
from utils.torch_utils import convert2cpu
def save_fc(fp, fc_model):
fc_model.bias.data.numpy().tofile(fp)
fc_model.weight.data.numpy().tofile(fp) | null |
6,052 | import argparse
import os
import time
import numpy as np
import sys
import warnings
import torch
import torch.utils.data.distributed
from tqdm import tqdm
from easydict import EasyDict as edict
from data_process.kitti_dataloader import create_val_dataloader
from models.model_utils import create_model
from utils.misc im... | null |
6,053 | import torch
def convert2cpu_long(gpu_matrix):
return torch.LongTensor(gpu_matrix.size()).copy_(gpu_matrix) | null |
6,054 | import torch
def to_cpu(tensor):
return tensor.detach().cpu() | null |
6,055 | from __future__ import division
import sys
import tqdm
import torch
import numpy as np
from shapely.geometry import Polygon
import data_process.kitti_bev_utils as bev_utils
The provided code snippet includes necessary dependencies for implementing the `load_classes` function. Write a Python function `def load_classes(... | Loads class labels at 'path' |
6,056 | from __future__ import division
import sys
import tqdm
import torch
import numpy as np
from shapely.geometry import Polygon
import data_process.kitti_bev_utils as bev_utils
The provided code snippet includes necessary dependencies for implementing the `rescale_boxes` function. Write a Python function `def rescale_boxe... | Rescales bounding boxes to the original shape |
6,057 | from __future__ import division
import sys
import tqdm
import torch
import numpy as np
from shapely.geometry import Polygon
import data_process.kitti_bev_utils as bev_utils
def nms_cpu(boxes, confs, nms_thresh=0.5):
"""
:param boxes: [num, 6]
:param confs: [num, num_classes]
:param nms_thresh:
:para... | Removes detections with lower object confidence score than 'conf_thres' and performs Non-Maximum Suppression to further filter detections. Returns detections with shape: (x, y, w, l, im, re, object_conf, class_score, class_pred) |
6,058 | import os
import torch
import time
def make_folder(folder_name):
if not os.path.exists(folder_name):
os.makedirs(folder_name)
# or os.makedirs(folder_name, exist_ok=True) | null |
6,059 | import os
import torch
import time
def time_synchronized():
torch.cuda.synchronize() if torch.cuda.is_available() else None
return time.time() | null |
6,060 | import copy
import os
import math
import torch
from torch.optim.lr_scheduler import LambdaLR
import torch.distributed as dist
import matplotlib.pyplot as plt
def plot_lr_scheduler(optimizer, scheduler, num_epochs=300, save_dir=''):
# Plot LR simulating training for full num_epochs
optimizer, scheduler = copy.c... | null |
6,061 | from __future__ import division
import sys
import torch
from shapely.geometry import Polygon
from scipy.spatial import ConvexHull
from utils.cal_intersection_rotated_boxes import intersection_area, PolyArea2D
def cvt_box_2_polygon(box):
"""
:param array: an array of shape [num_conners, 2]
:return: a shapely... | Args: box: (num_boxes, 4) --> w, l, im, re |
6,062 | from __future__ import division
import sys
import torch
from shapely.geometry import Polygon
from scipy.spatial import ConvexHull
from utils.cal_intersection_rotated_boxes import intersection_area, PolyArea2D
def iou_rotated_boxes_targets_vs_anchors(anchors_polygons, anchors_areas, targets_polygons, targets_areas):
... | null |
6,063 | from __future__ import division
import sys
import torch
from shapely.geometry import Polygon
from scipy.spatial import ConvexHull
from utils.cal_intersection_rotated_boxes import intersection_area, PolyArea2D
def cvt_box_2_polygon(box):
def get_corners_vectorize(x, y, w, l, yaw):
def intersection_area(rect1, rect2):
... | null |
6,064 | from __future__ import division
import sys
import torch
from shapely.geometry import Polygon
from scipy.spatial import ConvexHull
from utils.cal_intersection_rotated_boxes import intersection_area, PolyArea2D
def get_corners_torch(x, y, w, l, yaw):
device = x.device
bev_corners = torch.zeros((4, 2), dt... | null |
6,065 | import sys
import math
import numpy as np
import mayavi.mlab as mlab
import cv2
from data_process import kitti_data_utils, kitti_bev_utils, transformation
import config.kitti_config as cnf
The provided code snippet includes necessary dependencies for implementing the `draw_lidar_simple` function. Write a Python functi... | Draw lidar points. simplest set up. |
6,066 | import sys
import math
import numpy as np
import mayavi.mlab as mlab
import cv2
from data_process import kitti_data_utils, kitti_bev_utils, transformation
import config.kitti_config as cnf
The provided code snippet includes necessary dependencies for implementing the `show_image_with_boxes` function. Write a Python fu... | Show image with 2D bounding boxes |
6,067 | import sys
import math
import numpy as np
import mayavi.mlab as mlab
import cv2
from data_process import kitti_data_utils, kitti_bev_utils, transformation
import config.kitti_config as cnf
def draw_lidar(pc, color=None, fig1=None, bgcolor=(0, 0, 0), pts_scale=1, pts_mode='point', pts_color=None):
''' Draw lidar poi... | Show all LiDAR points. Draw 3d box in LiDAR point cloud (in velo coord system) |
6,068 | import sys
import math
import numpy as np
import mayavi.mlab as mlab
import cv2
from data_process import kitti_data_utils, kitti_bev_utils, transformation
import config.kitti_config as cnf
def merge_rgb_to_bev(img_rgb, img_bev, output_width):
img_rgb_h, img_rgb_w = img_rgb.shape[:2]
ratio_rgb = output_width / ... | null |
6,069 | import sys
import math
import numpy as np
import mayavi.mlab as mlab
import cv2
from data_process import kitti_data_utils, kitti_bev_utils, transformation
import config.kitti_config as cnf
def invert_target(targets, calib, img_shape_2d, RGB_Map=None):
predictions = targets
predictions = kitti_bev_utils.inverse... | null |
6,070 | import sys
import math
import numpy as np
import mayavi.mlab as mlab
import cv2
from data_process import kitti_data_utils, kitti_bev_utils, transformation
import config.kitti_config as cnf
def predictions_to_kitti_format(img_detections, calib, img_shape_2d, img_size, RGB_Map=None):
predictions = []
for detecti... | null |
6,071 | import torch
def get_corners_torch(x, y, w, l, yaw):
device = x.device
bev_corners = torch.zeros((4, 2), dtype=torch.float, device=device)
cos_yaw = torch.cos(yaw)
sin_yaw = torch.sin(yaw)
# front left
bev_corners[0, 0] = x - w / 2 * cos_yaw - l / 2 * sin_yaw
bev... | null |
6,072 | import math
import jittor as jt
from jittor import nn
def get_freq_indices(method):
assert method in ['top1', 'top2', 'top4', 'top8', 'top16', 'top32',
'bot1', 'bot2', 'bot4', 'bot8', 'bot16', 'bot32',
'low1', 'low2', 'low4', 'low8', 'low16', 'low32']
num_freq = int(... | null |
6,073 | import jittor as jt
from jittor import nn
import numpy as np
def affine_grid_generator(height, width, theta):
num_batch = theta.shape[0]
# create normalized 2D grid
x = jt.linspace(-1.0, 1.0, width)
y = jt.linspace(-1.0, 1.0, height)
x_t, y_t = jt.meshgrid(x, y)
# flatten
x_t_flat = x... | null |
6,074 | import jittor as jt
from jittor import nn
import numpy as np
def get_pixel_value(img, x, y):
B, C, H, W = img.shape
return img.reindex([B, C, H, W], ['i0', 'i1', '@e0(i0, i2, i3)','@e1(i0, i2, i3)'], extras=[x, y])
def bilinear_sampler(img, x, y):
B, C, H ,W = img.shape
max_y = H - 1
max_x = W - 1
... | null |
6,075 | import jittor as jt
from jittor import nn
from contextlib import contextmanager
def null_context():
yield | null |
6,076 | import jittor as jt
from jittor import nn
def make_divisible(v, divisor=8, min_value=None, round_limit=.9):
min_value = min_value or divisor
new_v = max(min_value, int(v + divisor / 2) // divisor * divisor)
# Make sure that round down does not go down by more than 10%.
if new_v < round_limit * v:
... | null |
6,077 | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
import collections
del collections, __Ver... | null |
6,078 | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
if pycompat.PY2:
from io import open
ipyt... | null |
6,079 | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
if pycompat.PY2:
from io import open
clas... | null |
6,080 | import abc
import re
import sys
from .pycompat import ABC, string_types, collections_abc
def _check_methods(C, *methods):
mro = C.__mro__
for method in methods:
for B in mro:
if method in B.__dict__:
if B.__dict__[method] is None:
return NotImplemented
... | null |
6,081 | import abc
import re
import sys
from .pycompat import ABC, string_types, collections_abc
def ensure_tuple(x):
if isinstance(x, collections_abc.Iterable) and \
not isinstance(x, string_types):
return tuple(x)
else:
return (x,) | null |
6,082 | import itertools
import abc
from copy import deepcopy
from . import utils
from . import pycompat
def needs_parentheses(source):
def code(s):
return compile(s, '<variable>', 'eval').co_code
return code('{}.x'.format(source)) != code('({}).x'.format(source)) | null |
6,083 | import abc
import os
import inspect
import sys
import datetime as datetime_module
if sys.version_info[:2] >= (3, 6):
time_isoformat = datetime_module.time.isoformat
else:
def time_isoformat(time, timespec='microseconds'):
assert isinstance(time, datetime_module.time)
if timespec != 'microseconds... | null |
6,084 | import abc
import os
import inspect
import sys
import datetime as datetime_module
def timedelta_parse(s):
hours, minutes, seconds, microseconds = map(
int,
s.replace('.', ':').split(':')
)
return datetime_module.timedelta(hours=hours, minutes=minutes,
se... | null |
6,085 | import setuptools
import re
def read_file(filename):
with open(filename) as file:
return file.read() | null |
6,086 | import subprocess
import sys
def iterate_authors_by_chronological_order(branch):
log_call = subprocess.run(
(
'git', 'log', branch, '--encoding=utf-8', '--full-history',
'--reverse', '--format=format:%at;%an;%ae'
),
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
... | null |
6,087 | import json
import random
import time
import math
import numpy as np
import torch
import torch.nn as nn
from torch.nn import functional as F
from torch.utils.data import Dataset
def to_float(x):
return x.cpu().detach().numpy().flatten()[0].astype(float) | null |
6,088 | import json
import random
import time
import math
import numpy as np
import torch
import torch.nn as nn
from torch.nn import functional as F
from torch.utils.data import Dataset
def set_seed(seed):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed) | null |
6,089 | from torch.utils.cpp_extension import load
import math
import numpy as np
import logging
import torch
import torch.nn as nn
from torch.nn import functional as F
def RWKV_Init(module, config): # fancy initialization of all lin & emb layer in the module
for m in module.modules():
if not isinstance(m, (nn.Li... | null |
6,090 | print('Loading...')
from src.model_run import RWKV_RNN
import numpy as np
import os, copy, types, gc, sys
import torch
from src.utils import TOKENIZER
tokenizer = TOKENIZER(WORD_NAME, UNKNOWN_CHAR=UNKNOWN_CHAR)
args = types.SimpleNamespace()
args.RUN_DEVICE = "cuda"
args.FLOAT_MODE = "fp16"
args.vocab_size = 50277
arg... | null |
6,091 | import json, time, random, os
import numpy as np
import torch
from torch.nn import functional as F
time_slot = {}
time_ref = time.time_ns()
def record_time(name):
if name not in time_slot:
time_slot[name] = 1e20
tt = (time.time_ns() - time_ref) / 1e9
if tt < time_slot[name]:
time_slot[name]... | null |
6,092 | import json, time, random, os
import numpy as np
import torch
from torch.nn import functional as F
def FermatPrimalityTest(number):
if number > 1:
for time in range(3):
randomNumber = random.randint(2, number) - 1
if pow(randomNumber, number - 1, number) != 1:
return ... | null |
6,093 | import os, math, time, datetime, subprocess
import torch
from torch.utils.data import DataLoader
import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info, rank_zero_only
def my_save(args, trainer, dd, ff):
if '14b-run1' in ff:
fn = ff.split('/')[-1]
fff = '/dev/shm/' + ... | null |
6,094 | import os, math, time, datetime, subprocess
import torch
from torch.utils.data import DataLoader
import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info, rank_zero_only
def generate_init_weight(model, init_weight_name):
mm = model.generate_init_weight()
if model.args.my_pile_stag... | null |
6,095 | from lib2to3.pgen2 import token
import os
import torch
import numpy as np
import shutil
import struct
from functools import lru_cache
from itertools import accumulate
def print_rank_0(*message):
pass
# """If distributed is initialized print only on rank 0."""
# if torch.distributed.is_initialized():
# ... | null |
6,096 | from lib2to3.pgen2 import token
import os
import torch
import numpy as np
import shutil
import struct
from functools import lru_cache
from itertools import accumulate
def _warmup_mmap_file(path):
pass
# with open(path, "rb") as stream:
# while stream.read(100 * 1024 * 1024):
# pass | null |
6,097 | from lib2to3.pgen2 import token
import os
import torch
import numpy as np
import shutil
import struct
from functools import lru_cache
from itertools import accumulate
dtypes = {
1: np.uint8,
2: np.int8,
3: np.int16,
4: np.int32,
5: np.int64,
6: float,
7: np.double,
8: np.uint16,
}
def c... | null |
6,098 | from lib2to3.pgen2 import token
import os
import torch
import numpy as np
import shutil
import struct
from functools import lru_cache
from itertools import accumulate
def index_file_path(prefix_path):
return prefix_path + ".idx" | null |
6,099 | from lib2to3.pgen2 import token
import os
import torch
import numpy as np
import shutil
import struct
from functools import lru_cache
from itertools import accumulate
def data_file_path(prefix_path):
return prefix_path + ".bin" | null |
6,100 | import types
import torch
import math, os, gc
from torch.nn import functional as F
import torch.nn as nn
from typing import List, Dict
def __nop(ob):
return ob | null |
6,101 | import os, math, gc, importlib
import torch
import torch.nn as nn
from torch.nn import functional as F
import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info, rank_zero_only
from pytorch_lightning.strategies import DeepSpeedStrategy
from torch.utils.cpp_extension import load
def __nop(ob... | null |
6,102 | import os, math, gc, importlib
import torch
import torch.nn as nn
from torch.nn import functional as F
import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info, rank_zero_only
from pytorch_lightning.strategies import DeepSpeedStrategy
from torch.utils.cpp_extension import load
if os.environ... | null |
6,103 | import os, math, gc, importlib
import torch
import torch.nn as nn
from torch.nn import functional as F
import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info, rank_zero_only
from pytorch_lightning.strategies import DeepSpeedStrategy
from torch.utils.cpp_extension import load
if 'r4' in os... | null |
6,104 | import numpy as np
import os, math, gc
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision as vision
import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info, rank_zero_only
from pytorch_lightning.strategies import DeepSpeedStrategy
import deepspeed
from de... | null |
6,105 | import numpy as np
import os, math, gc
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision as vision
import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info, rank_zero_only
from pytorch_lightning.strategies import DeepSpeedStrategy
import deepspeed
from de... | null |
6,106 | import numpy as np
import math, os, sys, types, time, gc
import torch
from src.utils import TOKENIZER
from src.model_run import RWKV_RNN
time_slot = {}
time_ref = time.time_ns()
def record_time(name):
if name not in time_slot:
time_slot[name] = 1e20
tt = (time.time_ns() - time_ref) / 1e9
if tt < ti... | null |
6,107 | import os
import json
import random
import numpy as np
import torch
from torch.nn import functional as F
from torch.utils.data import Dataset
def to_float(x):
return x.cpu().detach().numpy().flatten()[0].astype(float) | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.