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 | |
| import random | |
| import itertools | |
| import multiprocessing | |
| from typing import Optional, Callable, List, Tuple, Any, Dict, TypeVar | |
| __all__ = ['parallel_chunks_map'] | |
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 hashlib | |
| import functools | |
| import dataclasses | |
| import numpy as np | |
| from typing import List, Union, Optional, Tuple, Dict, Set, Any, final | |
| from typing_extensions import Protocol | |
| def seq_lengths_to_mask(seq_lengths: torch.LongTensor, max_seq_len: int, batch_first: bool = True): |
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, Union | |
| def apply_batched_embeddings( | |
| batched_embeddings: torch.Tensor, indices: torch.Tensor, | |
| mask: Optional[torch.Tensor] = None, padding_embedding_vector: Optional[torch.Tensor] = None, | |
| common_embeddings: Optional[Union[torch.Tensor, nn.Embedding]] = None) -> torch.Tensor: | |
| indices_device = indices.device |
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 networkx as nx | |
| import numpy as np | |
| def calc_number_of_simple_paths(graph: nx.DiGraph, s, t): | |
| num_of_simple_paths = np.full(graph.number_of_nodes(), np.nan) | |
| is_in_dfs_stack = np.full(graph.number_of_nodes(), 0) | |
| def _dfs(u): | |
| if is_in_dfs_stack[u]: | |
| return 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 typing | |
| import networkx as nx | |
| import numpy as np | |
| from enum import Enum | |
| __all__ = ['Agent', 'alpha_beta_rb_minimax'] | |
| class Agent(Enum): |
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 sys | |
| import typing | |
| import dataclasses | |
| import multiprocessing | |
| import functools | |
| import time | |
| import logging | |
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
| /* | |
| Based on: https://github.com/MartinPavlik/graphql-codegen-mongoose-schema | |
| */ | |
| import { | |
| GraphQLSchema, TypeInfo, | |
| } from 'graphql'; | |
| import { | |
| schemaToTemplateContext, | |
| AstNode, |
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 numpy as np | |
| from networkx import Graph, number_of_nodes | |
| from collections import deque | |
| from scipy.misc import comb | |
| class GraphWithNodesMappings(Graph): | |
| def __init__(self, *args, **kargs): | |
| super().__init__(*args, **kargs) | |
| self.__node_name_to_idx = {} |
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 numpy as np | |
| from collections import namedtuple | |
| from itertools import chain | |
| TaxStep = namedtuple('TaxStep', ['up_to', 'tax_percent']) | |
| # Israeli income salary tax steps; updated on the 21.04.18; taken from: | |
| # https://www.xn----1hcmgxnk8ede.co.il/%D7%9E%D7%93%D7%A8%D7%92%D7%95%D7%AA-%D7%9E%D7%A1 | |
| income_salary_tax_steps = [ | |
| TaxStep(up_to=6240, tax_percent=10), |
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 collections | |
| """ | |
| This is based on HeapDict 1.0.0, but includes a few modifications. | |
| https://pypi.org/project/HeapDict/ | |
| """ | |
| def doc(s): | |
| if hasattr(s, '__call__'): | |
| s = s.__doc__ |