def replace(tokens):
    """
    with contextlib.nested(a, b, c) as (x, y, z):
    ->
    with a as x, \\
        b as y, \\
        c as z:
    """
    leading_indent, nested_calls = tokens["leading indent"], tokens["nested calls"]
    lw = leading_indent[1:] if leading_indent.startswith("\n") else leading_indent
    if "as assignments" in tokens:
        as_assignments = tokens["as assignments"]
        assert len(nested_calls) == len(as_assignments)
        return (
            leading_indent + "with "
            + (", \\\n" + lw + "    ").join(
                nc.strip() + " as " + aa.strip()
                for nc, aa in zip(nested_calls, as_assignments)
            ) + ":"
        )
    else:
        return (
            leading_indent + "with "
            + (", \\\n" + lw + "    ").join(
                nc.strip() for nc in nested_calls
            ) + ":"
        )