def _remote_call(f, *args, **kwargs):
nargs = []<EOL>for a in args:<EOL><INDENT>if isinstance(a, Id):<EOL><INDENT>nargs.append(distob.engine[a])<EOL><DEDENT>elif (isinstance(a, collections.Sequence) and<EOL>not isinstance(a, string_types)):<EOL><INDENT>nargs.append(<EOL>[distob.engine[b] if isinstance(b, Id) else b for b in a])<EOL><DEDENT>else: nargs.append(a)<EOL><DEDENT>for k, a in kwargs.items():<EOL><INDENT>if isinstance(a, Id):<EOL><INDENT>kwargs[k] = distob.engine[a]<EOL><DEDENT>elif (isinstance(a, collections.Sequence) and<EOL>not isinstance(a, string_types)):<EOL><INDENT>kwargs[k] = [<EOL>distob.engine[b] if isinstance(b, Id) else b for b in a]<EOL><DEDENT><DEDENT>result = f(*nargs, **kwargs)<EOL>if (isinstance(result, collections.Sequence) and<EOL>not isinstance(result, string_types)):<EOL><INDENT>results = []<EOL>for subresult in result:<EOL><INDENT>if type(subresult) in distob.engine.proxy_types: <EOL><INDENT>results.append(Ref(subresult))<EOL><DEDENT>else:<EOL><INDENT>results.append(subresult)<EOL><DEDENT><DEDENT>return results<EOL><DEDENT>elif type(result) in distob.engine.proxy_types:<EOL><INDENT>return Ref(result)<EOL><DEDENT>else:<EOL><INDENT>return result<EOL><DEDENT>
(Executed on remote engine) convert Ids to real objects, call f