This file contains hidden or 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
| __author__ = "Elad Nachmias" | |
| __email__ = "eladnah@gmail.com" | |
| __date__ = "2023-10-18" | |
| import dataclasses | |
| import enum | |
| import itertools | |
| import warnings | |
| from collections import defaultdict, Counter | |
| from typing import Optional, Dict, List, Sequence, Iterable, Union, Set, Tuple |
This file contains hidden or 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
| __author__ = "Elad Nachmias" | |
| __email__ = "eladnah@gmail.com" | |
| __date__ = "2023-10-18" | |
| import base64 | |
| import functools | |
| import hashlib | |
| from typing import Any, Set, Optional, NamedTuple, Dict | |
| import dataclasses |
This file contains hidden or 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
| __author__ = "Elad Nachmias" | |
| __email__ = "eladnah@gmail.com" | |
| __date__ = "2023-10-18" | |
| import ctypes | |
| import math | |
| import signal | |
| import threading | |
| import time | |
| import traceback |
This file contains hidden or 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
| #include <iostream> | |
| #include <sstream> | |
| using namespace std; | |
| void permutations(string str) { | |
| // factorials[i] = i! for i in [0..|str|] | |
| uint64_t factorials[str.length() + 1]; | |
| factorials[0] = 1; | |
| for(int i = 1; i <= str.length(); i++) { |
This file contains hidden or 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 | |
| __all__ = ['format_time', 'find_pretty_time_fmt', 'prettify_time'] | |
| possible_time_fmts = ('secs', 'mins', 'hours', 'days', 'months', 'years', 'thousand years', 'million years') | |
| time_fmts_divisors = { | |
| 'secs': 1, 'mins': 60, 'hours': 60*60, 'days': 60*60*24, 'months': 60*60*24*30, | |
| 'years': 60*60*24*365, 'thousand years': 60*60*24*365*1_000, | |
| 'million years': 60*60*24*365*1_000_000} | |
| assert set(time_fmts_divisors.keys()) == set(possible_time_fmts) |
This file contains hidden or 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 torch | |
| import torch.nn as nn | |
| from typing import Optional, Tuple | |
| from torch_scatter import scatter_sum, scatter_softmax | |
| __all__ = ['ScatterAttention'] | |
| class ScatterAttention(nn.Module): |
This file contains hidden or 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 torch | |
| from typing import List, Tuple, Union | |
| __all__ = ['weave_tensors', 'unweave_tensor'] | |
| def weave_tensors( | |
| tensors: Union[List[torch.Tensor], Tuple[torch.Tensor, ...]], dim: int = 0): | |
| assert len(tensors) > 0 |
This file contains hidden or 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 multiprocessing as mp | |
| __all__ = ['AsyncNotifyChannel'] | |
| class CloseNotifyProcessAction: | |
| pass | |
This file contains hidden or 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 os | |
| import io | |
| import torch | |
| import dbm | |
| import itertools | |
| import numpy as np | |
| from warnings import warn | |
| from typing import Optional, Mapping, ByteString | |
| from torch.utils.data.dataset import Dataset |
This file contains hidden or 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 functools | |
| import dataclasses | |
| from typing import TypeVar, Generic, List, Tuple, Dict, Iterator | |
| __all__ = ['TrieNode'] | |
| SequenceElementType = TypeVar('SequenceElementType') | |
| SequenceType = Tuple[SequenceElementType, ...] |