def METHOD_NAME(tokens):
  """Separate tokens into logical lines.
  Arguments:
    tokens: (list of tokenizer.TokenInfo) Tokens generated by tokenizer.
  Returns:
    A list of LogicalLines.
  """
  formatted_tokens = []
  # Convert tokens into "TokenInfo" and add tokens for continuation markers.
  prev_tok = None
  for tok in tokens:
    tok = TokenInfo(*tok)
    if (prev_tok and prev_tok.line.rstrip().endswith('\\') and
        prev_tok.start[0] < tok.start[0]):
      ctok = TokenInfo(
          type=CONTINUATION,
          string='\\',
          start=(prev_tok.start[0], prev_tok.start[1] + 1),
          end=(prev_tok.end[0], prev_tok.end[0] + 2),
          line=prev_tok.line)
      ctok.lineno = ctok.start[0]
      ctok.column = ctok.start[1]
      ctok.value = '\\'
      formatted_tokens.append(format_token.FormatToken(ctok, 'CONTINUATION'))
    tok.lineno = tok.start[0]
    tok.column = tok.start[1]
    tok.value = tok.string
    formatted_tokens.append(
        format_token.FormatToken(tok, token.tok_name[tok.type]))
    prev_tok = tok
  # Generate logical lines.
  logical_lines, cur_logical_line = [], []
  depth = 0
  for tok in formatted_tokens:
    if tok.type == tokenize.ENDMARKER:
      break
    if tok.type == tokenize.NEWLINE:
      # End of a logical line.
      logical_lines.append(logical_line.LogicalLine(depth, cur_logical_line))
      cur_logical_line = []
    elif tok.type == tokenize.INDENT:
      depth += 1
    elif tok.type == tokenize.DEDENT:
      depth -= 1
    elif tok.type == tokenize.NL:
      pass
    else:
      if (cur_logical_line and not tok.type == tokenize.COMMENT and
          cur_logical_line[0].type == tokenize.COMMENT):
        # We were parsing a comment block, but now we have real code to worry
        # about. Store the comment and carry on.
        logical_lines.append(logical_line.LogicalLine(depth, cur_logical_line))
        cur_logical_line = []
      cur_logical_line.append(tok)
  # Link the FormatTokens in each line together to form a doubly linked list.
  for line in logical_lines:
    previous = line.first
    bracket_stack = [previous] if previous.OpensScope() else []
    for tok in line.tokens[1:]:
      tok.previous_token = previous
      previous.next_token = tok
      previous = tok
      # Set up the "matching_bracket" attribute.
      if tok.OpensScope():
        bracket_stack.append(tok)
      elif tok.ClosesScope():
        bracket_stack[-1].matching_bracket = tok
        tok.matching_bracket = bracket_stack.pop()
  return logical_lines