Call the function `tower_fn` under :class:`TowerContext` for each tower.

        Returns:
            a list, contains the return values of `tower_fn` on each tower.
347078
def call_for_each_tower(self, tower_fn):
        
        ps_device = 'cpu' if len(self.towers) >= 4 else 'gpu'

        raw_devices = ['/gpu:{}'.format(k) for k in self.towers]
        if ps_device == 'gpu':
            devices = [LeastLoadedDeviceSetter(d, raw_devices) for d in raw_devices]
        else:
            devices = [tf.train.replica_device_setter(
                worker_device=d, ps_device='/cpu:0', ps_tasks=1) for d in raw_devices]

        return DataParallelBuilder.build_on_towers(self.towers, tower_fn, devices)
150435
def map(self, func):
        
        return TList([func(k, v) for k, v in self.items()])
95331
def _fill_function(func, globals, defaults, dict, module, closure_values):
    
    func.__globals__.update(globals)
    func.__defaults__ = defaults
    func.__dict__ = dict
    func.__module__ = module

    cells = func.__closure__
    if cells is not None:
        for cell, value in zip(cells, closure_values):
            if value is not _empty_cell_value:
                cell_set(cell, value)

    return func
1204370
def functions(self):
        
        return [v for v in self.globals.values()
                if isinstance(v, values.Function)]
325367
def member_functions(
            self,
            name=None,
            function=None,
            return_type=None,
            arg_types=None,
            header_dir=None,
            header_file=None,
            recursive=None,
            allow_empty=None):
        """"""
        return (
            self._find_multiple(
                self._impl_matchers[scopedef_t.member_function],
                name=name,
                function=function,
                decl_type=self._impl_decl_types[
                    scopedef_t.member_function],
                return_type=return_type,
                arg_types=arg_types,
                header_dir=header_dir,
                header_file=header_file,
                recursive=recursive,
                allow_empty=allow_empty)
        )
448073
function(fn) {
		return function() {
			var realArgs = [];
			var fnArgs = arguments;
			each(fnArgs, function(val, i) {
				if (i <= fnArgs.length) {
					while (val && val.isComputed) {
						val = val();
					}
					realArgs.push(val);
				}
			});
			return fn.apply(this, realArgs);
		};
	}
357964
def functions(self):
        
        return [x for x in self[self.current_scope].values() if x.class_ in
                (CLASS.function, CLASS.sub)]
136242
def find(self, func: Callable[[K, T], bool]) -> TOption[T]:
        
        for k, v in self.items():
            if func(k, v):
                return TOption(v)
        return TOption(None)
39092
def ctx(self):
        '''
        
        '''
        if six.PY2:
            return contextlib.nested(
                self.functions.context_dict.clone(),
                self.returners.context_dict.clone(),
                self.executors.context_dict.clone(),
            )
        else:
            exitstack = contextlib.ExitStack()
            exitstack.enter_context(self.functions.context_dict.clone())
            exitstack.enter_context(self.returners.context_dict.clone())
            exitstack.enter_context(self.executors.context_dict.clone())
            return exitstack
411572
def filter(self, func):
        # type: (Callable[[BaseCollection], bool]) -> _CollectionGroupBy
        
        results = OrderedDict()  # type: OrderedDict
        for name, group in self:
            if func(group):
                results[name] = group

        return self.__class__(results)
1033113
def _get_callargs(self, *args, **kwargs):
        
        callargs = getcallargs(self.func, *args, **kwargs)
        return callargs
906133
def get_current_args(caller_level = 0, func = None, argNames = None):
    
    if argNames is None:
        argNames = getargnames(getargspecs(func))
    if func is None:
        func = get_current_function(caller_level+1)
    if isinstance(func, property):
        func = func.fget if func.fset is None else func.fset
    stck = inspect.stack()
    lcs = stck[1+caller_level][0].f_locals
    return tuple([lcs[t] for t in argNames])
1343840
def context_processor(self, fn):
        
        self._defer(lambda bp: bp.context_processor(fn))
        return fn
220091
function (fn, context) {
            var args = [];
            for (var i = 2; i < arguments.length; i++) {
                args.push(arguments[i]);
            }
            return function () {
                // need to make a copy each time
                var finalArgs = args.slice(0);
                // concat won't work, as arguments is a special array
                for (var i = 0; i < arguments.length; i++) {
                    finalArgs.push(arguments[i]);
                }
                return fn.apply(context, finalArgs);
            };
        }
44410
def CallUDFUNS(f, x):
    
    value = c_double()
    f(x, byref(value))
    return value.value
322938
def foreach(self, func):
        
        if self.mode == 'spark':
            self.values.tordd().map(lambda kv: (kv[0][0], kv[1])).foreach(func)
        else:
            [func(kv) for kv in enumerate(self.values)]
825664
def get_stack(self, f, t):
        """"""
        stack = []
        if t and t.tb_frame == f:
            t = t.tb_next
        while f is not None:
            stack.append((f, f.f_lineno))
            f = f.f_back
        stack.reverse()
        i = max(0, len(stack) - 1)
        while t is not None:
            stack.append((t.tb_frame, t.tb_lineno))
            t = t.tb_next
        if f is None:
            i = max(0, len(stack) - 1)
        return stack, i