<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dedent(string, indent_str=' ', max_levels=None):
 """Revert the effect of indentation. Examples -------- Remove a simple one-level indentation: <->This is line 1. <->Next line. <->And another one. This is line 1. Next line. And another one. Multiple levels of indentation: <->Level 1. <-><->Level 2. <-><-><->Level 3. Level 1. <->Level 2. <-><->Level 3. <-><->Level 2. <-><-><->Level 3. Level 2. <->Level 3. <->Level 2. <-><->Level 3. """

    if len(indent_str) == 0:
        return string

    lines = string.splitlines()

    # Determine common (minumum) number of indentation levels, capped at
    # `max_levels` if given
    def num_indents(line):
        max_num = int(np.ceil(len(line) / len(indent_str)))

        for i in range(max_num):
            if line.startswith(indent_str):
                line = line[len(indent_str):]
            else:
                break

        return i

    num_levels = num_indents(min(lines, key=num_indents))
    if max_levels is not None:
        num_levels = min(num_levels, max_levels)

    # Dedent
    dedent_len = num_levels * len(indent_str)
    return '\n'.join(line[dedent_len:] for line in lines)