code: def extract_words_for_page(
      page: pdfplumber.page.Page,
      x_tolerance=1.5,
      y_tolerance=2,
      keep_blank_chars=False,
      use_text_flow=True,
      horizontal_ltr=True,
      vertical_ttb=True,
      extra_attrs=None,
  ) -> Layout:
      """The helper function used for extracting words from a pdfplumber page
      object.
  
      Returns:
          Layout: a layout object representing all extracted pdf tokens on this page.
      """
      if extra_attrs is None:
          extra_attrs = ["fontname", "size"]
  
      tokens = page.extract_words(
          x_tolerance=x_tolerance,
          y_tolerance=y_tolerance,
          keep_blank_chars=keep_blank_chars,
          use_text_flow=use_text_flow,
          horizontal_ltr=horizontal_ltr,
          vertical_ttb=vertical_ttb,
          extra_attrs=extra_attrs,
      )
  
      df = pd.DataFrame(tokens)
  
      if len(df) == 0:
          return Layout()
  
      df[["x0", "x1"]] = (
          df[["x0", "x1"]]
          .clip(lower=0, upper=int(page.width))
          .astype("float")
      )
      df[["top", "bottom"]] = (
          df[["top", "bottom"]]
          .clip(lower=0, upper=int(page.height))
          .astype("float")
      )
  
      page_tokens = load_dataframe(
          df.reset_index().rename(
              columns={
                  "x0": "x_1",
                  "x1": "x_2",
                  "top": "y_1",
                  "bottom": "y_2",
                  "index": "id",
                  "fontname": "type",  # also loading fontname as "type"
              }
          ),
          block_type="rectangle",
      )
  
      return page_tokens
  
imports: from typing import List, Union, Optional, Dict, Tuple
  import pdfplumber
  import pandas
  from ..elements import Layout
  from .basic import load_dataframe
label_desc: Use image node_id 1 for calling a global function with example usage: extract_words_for_page(page, x_tolerance, y_tolerance, keep_blank_chars, use_text_flow, horizontal_ltr, vertical_ttb, extra_attrs) and returns: page_tokens, Layout