Neighborhood Equivalence Class tree (see Turbo_ISO paper)
518446
def _isomorphism_rewrite_to_NECtree(q_s, qgraph):
    
    qadj = qgraph.adj
    adjsets = lambda x: set(chain.from_iterable(qadj[x].values()))
    t = ([q_s], [])  # (NEC_set, children)
    visited = {q_s}
    vcur, vnext = [t], []
    while vcur:
        for (nec, children) in vcur:
            c = defaultdict(list)
            for u in nec:
                for sig, adjlist in qadj[u].items():
                    c[sig].extend(x for x, _, _ in adjlist if x not in visited)
            for sig, c_adjlist in c.items():
                visited.update(c_adjlist)
                # these are already grouped by label; now group by adjacents
                for key, grp in groupby(c_adjlist, key=adjsets):
                    grp = list(grp)
                    if len(grp) > 1:
                        children.append((list(grp), []))
                    else:
                        # NOTE: the paper says to look for mergeable things,
                        # but I don't know what else to merge by.
                        children.append((list(grp), []))
            vnext.extend(children)
        vcur, vnext = vnext, []
    return t
623384
function ( fromObj, toObj, circularReference ) {
            circularReference = typeof circularReference === 'boolean' ? circularReference : true;
    
            var result = fromObj;
    
            if ( !circularReference ) {
                result = deepClone( fromObj );
                toObj = deepClone( toObj );
            }
    
            for ( var key in toObj ) {
                result[key] = toObj[key];
            }
    
            return result;
        }
737186
function classify (s) {
  const keys = {
    ak: 'account_pubkey',
    ok: 'oracle_pubkey'
  }

  if (!s.match(/^[a-z]{2}_.+/)) {
    throw Error('Not a valid hash')
  }

  const klass = s.substr(0, 2)
  if (klass in keys) {
    return keys[klass]
  } else {
    throw Error(`Unknown class ${klass}`)
  }
}
1288040
function tinf_decode_trees(d, lt, dt) {
  var hlit, hdist, hclen;
  var i, num, length;

  /* get 5 bits HLIT (257-286) */
  hlit = tinf_read_bits(d, 5, 257);

  /* get 5 bits HDIST (1-32) */
  hdist = tinf_read_bits(d, 5, 1);

  /* get 4 bits HCLEN (4-19) */
  hclen = tinf_read_bits(d, 4, 4);

  for (i = 0; i < 19; ++i) lengths[i] = 0;

  /* read code lengths for code length alphabet */
  for (i = 0; i < hclen; ++i) {
    /* get 3 bits code length (0-7) */
    var clen = tinf_read_bits(d, 3, 0);
    lengths[clcidx[i]] = clen;
  }

  /* build code length tree */
  tinf_build_tree(code_tree, lengths, 0, 19);

  /* decode code lengths for the dynamic trees */
  for (num = 0; num < hlit + hdist;) {
    var sym = tinf_decode_symbol(d, code_tree);

    switch (sym) {
      case 16:
        /* copy previous code length 3-6 times (read 2 bits) */
        var prev = lengths[num - 1];
        for (length = tinf_read_bits(d, 2, 3); length; --length) {
          lengths[num++] = prev;
        }
        break;
      case 17:
        /* repeat code length 0 for 3-10 times (read 3 bits) */
        for (length = tinf_read_bits(d, 3, 3); length; --length) {
          lengths[num++] = 0;
        }
        break;
      case 18:
        /* repeat code length 0 for 11-138 times (read 7 bits) */
        for (length = tinf_read_bits(d, 7, 11); length; --length) {
          lengths[num++] = 0;
        }
        break;
      default:
        /* values 0-15 represent the actual code lengths */
        lengths[num++] = sym;
        break;
    }
  }

  /* build dynamic trees */
  tinf_build_tree(lt, lengths, 0, hlit);
  tinf_build_tree(dt, lengths, hlit, hdist);
}
66956
def simplify_recursive(typ):
    # type: (AbstractType) -> AbstractType
    """"""
    if isinstance(typ, UnionType):
        return combine_types(typ.items)
    elif isinstance(typ, ClassType):
        simplified = ClassType(typ.name, [simplify_recursive(arg) for arg in typ.args])
        args = simplified.args
        if (simplified.name == 'Dict' and len(args) == 2
                and isinstance(args[0], ClassType) and args[0].name in ('str', 'Text')
                and isinstance(args[1], UnionType) and not is_optional(args[1])):
            # Looks like a potential case for TypedDict, which we don't properly support yet.
            return ClassType('Dict', [args[0], AnyType()])
        return simplified
    elif isinstance(typ, TupleType):
        return TupleType([simplify_recursive(item) for item in typ.items])
    return typ
440556
def _precompute(self, tree):
        
        d = {}
        for n in tree.preorder_internal_node_iter():
            d[n] = namedtuple('NodeDist', ['dist_from_root', 'edges_from_root'])
            if n.parent_node:
                d[n].dist_from_root = d[n.parent_node].dist_from_root + n.edge_length
                d[n].edges_from_root = d[n.parent_node].edges_from_root + 1
            else:
                d[n].dist_from_root = 0.0
                d[n].edges_from_root = 0
        return d
959589
def get_klass_children(gi_name):
    '''
    
    '''
    res = {}
    children = __HIERARCHY_GRAPH.successors(gi_name)
    for gi_name in children:
        ctype_name = ALL_GI_TYPES[gi_name]
        qs = QualifiedSymbol(type_tokens=[Link(None, ctype_name, ctype_name)])
        qs.add_extension_attribute ('gi-extension', 'type_desc',
                SymbolTypeDesc([], gi_name, ctype_name, 0))
        res[ctype_name] = qs
    return res
105871
def get_subclass_tree(cls, ensure_unique=True):
    """"""
    subclasses = []
    # cls.__subclasses__() fails on classes inheriting from type
    for subcls in type.__subclasses__(cls):
        subclasses.append(subcls)
        subclasses.extend(get_subclass_tree(subcls, ensure_unique))
    return list(set(subclasses)) if ensure_unique else subclasses
403219
def map(cls, iterable, func, *a, **kw):
    

    return cls(func(x, *a, **kw) for x in iterable)
62035
function shallowEqual(objA, objB) {
  if (isSameRef(objA, objB)) {
    return true;
  }

  if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
    return false;
  }

  var keysA = Object.keys(objA);
  var keysB = Object.keys(objB);

  if (keysA.length !== keysB.length) {
    return false;
  }

  var _iteratorNormalCompletion4 = true;
  var _didIteratorError4 = false;
  var _iteratorError4 = undefined;

  try {
    for (var _iterator4 = keysA[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
      var k = _step4.value;

      if (!objB.hasOwnProperty(k)) {
        return false;
      } else if (!isSameRef(objA[k], objB[k])) {
        return false;
      }
    }
  } catch (err) {
    _didIteratorError4 = true;
    _iteratorError4 = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion4 && _iterator4.return) {
        _iterator4.return();
      }
    } finally {
      if (_didIteratorError4) {
        throw _iteratorError4;
      }
    }
  }

  return true;
}
253632
function ast(kind) {
    let properties = Array.prototype.slice.call(arguments, 1).reverse();
    return (stack, cb) => {
        let node = { kind: kind };
        properties.forEach(name => {
            if (name.endsWith('?')) {
                name = name.slice(0, -1);
                let o = stack[stack.length - 1];
                if (typeof o === 'object' && name in o) {
                    node[name] = stack.pop()[name];
                }
            } else {
                node[name] = stack.pop();
            }
        });
        stack.push(node);
        cb();
    };
}
795223
private static boolean areEqualWithGenerics(ClassNode a, ClassNode b) {
        if (a==null) return b==null;
        if (!a.equals(b)) return false;
        if (a.isUsingGenerics() && !b.isUsingGenerics()) return false;
        GenericsType[] gta = a.getGenericsTypes();
        GenericsType[] gtb = b.getGenericsTypes();
        if (gta==null && gtb!=null) return false;
        if (gtb==null && gta!=null) return false;
        if (gta!=null && gtb!=null) {
            if (gta.length!=gtb.length) return false;
            for (int i = 0; i < gta.length; i++) {
                GenericsType ga = gta[i];
                GenericsType gb = gtb[i];
                boolean result = ga.isPlaceholder()==gb.isPlaceholder() && ga.isWildcard()==gb.isWildcard();
                result = result && ga.isResolved() && gb.isResolved();
                result = result && ga.getName().equals(gb.getName());
                result = result && areEqualWithGenerics(ga.getType(), gb.getType());
                result = result && areEqualWithGenerics(ga.getLowerBound(), gb.getLowerBound());
                if (result) {
                    ClassNode[] upA = ga.getUpperBounds();
                    if (upA!=null) {
                        ClassNode[] upB = gb.getUpperBounds();
                        if (upB==null || upB.length!=upA.length) return false;
                        for (int j = 0; j < upA.length; j++) {
                            if (!areEqualWithGenerics(upA[j],upB[j])) return false;
                        }
                    }
                }
                if (!result) return false;
            }
        }
        return true;
    }
874225
function build_tree(clens, cmap, MAX) {
	var maxlen = 1, w = 0, i = 0, j = 0, ccode = 0, L = clens.length;

	var bl_count  = use_typed_arrays ? new Uint16Array(32) : zero_fill_array(32);
	for(i = 0; i < 32; ++i) bl_count[i] = 0;

	for(i = L; i < MAX; ++i) clens[i] = 0;
	L = clens.length;

	var ctree = use_typed_arrays ? new Uint16Array(L) : zero_fill_array(L); // []

	/* build code tree */
	for(i = 0; i < L; ++i) {
		bl_count[(w = clens[i])]++;
		if(maxlen < w) maxlen = w;
		ctree[i] = 0;
	}
	bl_count[0] = 0;
	for(i = 1; i <= maxlen; ++i) bl_count[i+16] = (ccode = (ccode + bl_count[i-1])<<1);
	for(i = 0; i < L; ++i) {
		ccode = clens[i];
		if(ccode != 0) ctree[i] = bl_count[ccode+16]++;
	}

	/* cmap[maxlen + 4 bits] = (off&15) + (lit<<4) reverse mapping */
	var cleni = 0;
	for(i = 0; i < L; ++i) {
		cleni = clens[i];
		if(cleni != 0) {
			ccode = bit_swap_n(ctree[i], maxlen)>>(maxlen-cleni);
			for(j = (1<<(maxlen + 4 - cleni)) - 1; j>=0; --j)
				cmap[ccode|(j<<cleni)] = (cleni&15) | (i<<4);
		}
	}
	return maxlen;
}
389383
private Optional<MutableQueryModifiers> extractTopQueryModifiers(IQ query) {
		IQTree tree = query.getTree();
		QueryNode rootNode = tree.getRootNode();
		if (rootNode instanceof QueryModifierNode) {
			Optional<SliceNode> sliceNode = Optional.of(rootNode)
					.filter(n -> n instanceof SliceNode)
					.map(n -> (SliceNode)n);

			IQTree firstNonSliceTree = sliceNode
					.map(n -> ((UnaryIQTree) tree).getChild())
					.orElse(tree);

			Optional<DistinctNode> distinctNode = Optional.of(firstNonSliceTree)
					.map(IQTree::getRootNode)
					.filter(n -> n instanceof DistinctNode)
					.map(n -> (DistinctNode) n);

			IQTree firstNonSliceDistinctTree = distinctNode
					.map(n -> ((UnaryIQTree) firstNonSliceTree).getChild())
					.orElse(firstNonSliceTree);

			Optional<OrderByNode> orderByNode = Optional.of(firstNonSliceDistinctTree)
					.map(IQTree::getRootNode)
					.filter(n -> n instanceof OrderByNode)
					.map(n -> (OrderByNode) n);

			MutableQueryModifiers mutableQueryModifiers = new MutableQueryModifiersImpl();

			sliceNode.ifPresent(n -> {
							n.getLimit()
									.ifPresent(mutableQueryModifiers::setLimit);
							long offset = n.getOffset();
							if (offset > 0)
								mutableQueryModifiers.setOffset(offset);
					});

			if(distinctNode.isPresent())
				mutableQueryModifiers.setDistinct();

			orderByNode
					.ifPresent(n -> n.getComparators()
							.forEach(c -> convertOrderComparator(c, mutableQueryModifiers)));

			return Optional.of(mutableQueryModifiers);
		}
		else
			return Optional.empty();
	}
1359438
def _parallel_compare_helper(class_obj, pairs, x, x_link=None):
    """"""
    return class_obj._compute(pairs, x, x_link)
723015
def convert_instancenorm(node, **kwargs):
    
    name, input_nodes, attrs = get_inputs(node, kwargs)

    eps = float(attrs.get("eps", 0.001))

    node = onnx.helper.make_node(
        'InstanceNormalization',
        inputs=input_nodes,
        outputs=[name],
        name=name,
        epsilon=eps)

    return [node]
991122
def _typelist(x):
    """"""
    if isinstance(x, collections.Sequence):
        return list(map(_to_instance, x))
    elif isinstance(x, collections.Iterable):
        return x
    return None if x is None else [_to_instance(x)]