'Group function arguments into categories.'

def _partition_args(self, args):

    py_args = []
    py_returns = []
    py_locals = []
    py_inferred = {}
    for arg in args:
        if isinstance(arg, OutputArgument):
            py_returns.append(arg)
            py_locals.append(arg)
        elif isinstance(arg, InOutArgument):
            py_returns.append(arg)
            py_args.append(arg)
        else:
            py_args.append(arg)
        if (isinstance(arg, (InputArgument, InOutArgument)) and arg.dimensions):
            dims = [(d[1] + 1) for d in arg.dimensions]
            sym_dims = [(i, d) for (i, d) in enumerate(dims) if isinstance(d, Symbol)]
            for (i, d) in sym_dims:
                py_inferred[d] = (arg.name, i)
    for arg in args:
        if (arg.name in py_inferred):
            py_inferred[arg] = py_inferred.pop(arg.name)
    py_args = [a for a in py_args if (a not in py_inferred)]
    return (py_returns, py_args, py_locals, py_inferred)
