code: def _extract_limit_from_query(statement: TokenList) -> Optional[int]:
      """
      Extract limit clause from SQL statement.
  
      :param statement: SQL statement
      :return: Limit extracted from query, None if no limit present in statement
      """
      idx, _ = statement.token_next_by(m=(Keyword, "LIMIT"))
      if idx is not None:
          _, token = statement.token_next(idx=idx)
          if token:
              if isinstance(token, IdentifierList):
                  # In case of "LIMIT <offset>, <limit>", find comma and extract
                  # first succeeding non-whitespace token
                  idx, _ = token.token_next_by(
                      m=(sqlparse.tokens.Punctuation, ",")
                  )
                  _, token = token.token_next(idx=idx)
              if (
                  token
                  and token.ttype
                  == sqlparse.tokens.Literal.Number.Integer
              ):
                  return int(token.value)
      return None
  
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 1 for calling a global function with example usage: _extract_limit_from_query(statement) and returns: None, int