This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Permutations<T, O = T> = [T] extends [never] ? [] : T extends any ? [T, ...Permutations<Exclude<O, T>>] : never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type JoinPath<A extends readonly string[]> = A extends readonly [infer K] | |
? K extends string | |
? K | |
: never | |
: A extends readonly [infer K, ...infer Rest] | |
? K extends string | |
? Rest extends readonly string[] | |
? `${K}.${JoinPath<Rest>}` | |
: never | |
: never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import operator | |
from multiprocessing import Pool | |
from typing import List | |
import torch | |
import random | |
import os | |
import numpy as np | |
from fuzzywuzzy import fuzz | |
from torch.utils.data import DataLoader, Dataset, RandomSampler, DistributedSampler, SequentialSampler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type PrimaryKey<Type> = Metadata<Type, 'primaryKey', { primaryKey: true }>; | |
export type BackReference<ReferencedBy, RelationName extends string> = Metadata< | |
ReferencedBy, | |
'backReference', | |
{ backReference: true; relationName: RelationName } | |
>; | |
export type GetBackReferenceRelationNames<Entity> = string & | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Yields promises as they settle. | |
* @param promises List of promise to yield through | |
*/ | |
export default async function* PromiseIterator<P>(promises: Iterable<Promise<P>>): AsyncGenerator<[Promise<P>], void, void> { | |
const pending = new Set<Promise<P>>(promises) | |
const settled = new Set<Promise<P>>() | |
// Move pending promises to `settled` when they settle | |
pending.forEach((promise) => |