code: def get_cte_remainder_query(sql: str) -> tuple[Optional[str], str]:
      """
      parse the SQL and return the CTE and rest of the block to the caller
  
      :param sql: SQL query
      :return: CTE and remainder block to the caller
  
      """
      cte: Optional[str] = None
      remainder = sql
      stmt = sqlparse.parse(sql)[0]
  
      # The first meaningful token for CTE will be with WITH
      idx, token = stmt.token_next(-1, skip_ws=True, skip_cm=True)
      if not (token and token.ttype == CTE):
          return cte, remainder
      idx, token = stmt.token_next(idx)
      idx = stmt.token_index(token) + 1
  
      # extract rest of the SQLs after CTE
      remainder = "".join(
          str(token) for token in stmt.tokens[idx:]
      ).strip()
      cte = f"WITH {token.value}"
  
      return cte, remainder
  
imports: import logging
  import re
  from collections.abc import Iterator
  from dataclasses import dataclass
  from typing import Any, cast, Optional
  from urllib import parse
  import sqlparse
  from sqlalchemy import and_
  from sqlparse import keywords
  from sqlparse.lexer import Lexer
  from sqlparse.sql import Identifier, IdentifierList, Parenthesis, remove_quotes, Token, TokenList, Where
  from sqlparse.tokens import Comment, CTE, DDL, DML, Keyword, Name, Punctuation, String, Whitespace, Wildcard
  from sqlparse.utils import imt
  from superset.exceptions import QueryClauseValidationException
  from superset.utils.backports import StrEnum
label_desc: Use image node_id 3 for calling a global function with example usage: get_cte_remainder_query(sql) and returns: cte,  remainder, cte,  remainder