code: def _parse_latex_header_span(
      cell: dict[str, Any],
      multirow_align: str,
      multicol_align: str,
      wrap: bool = False,
      convert_css: bool = False,
  ) -> str:
      r"""
      Refactor the cell `display_value` if a 'colspan' or 'rowspan' attribute is present.
  
      'rowspan' and 'colspan' do not occur simultaneouly. If they are detected then
      the `display_value` is altered to a LaTeX `multirow` or `multicol` command
      respectively, with the appropriate cell-span.
  
      ``wrap`` is used to enclose the `display_value` in braces which is needed for
      column headers using an siunitx package.
  
      Requires the package {multirow}, whereas multicol support is usually built in
      to the {tabular} environment.
  
      Examples
      --------
      >>> cell = {'cellstyle': '', 'display_value':'text', 'attributes': 'colspan="3"'}
      >>> _parse_latex_header_span(cell, 't', 'c')
      '\\multicolumn{3}{c}{text}'
      """
      display_val = _parse_latex_cell_styles(
          cell["cellstyle"], cell["display_value"], convert_css
      )
      if "attributes" in cell:
          attrs = cell["attributes"]
          if 'colspan="' in attrs:
              colspan = attrs[
                  attrs.find('colspan="') + 9 :
              ]  # len('colspan="') = 9
              colspan = int(colspan[: colspan.find('"')])
              if "naive-l" == multicol_align:
                  out = (
                      f"{{{display_val}}}" if wrap else f"{display_val}"
                  )
                  blanks = " & {}" if wrap else " &"
                  return out + blanks * (colspan - 1)
              elif "naive-r" == multicol_align:
                  out = (
                      f"{{{display_val}}}" if wrap else f"{display_val}"
                  )
                  blanks = "{} & " if wrap else "& "
                  return blanks * (colspan - 1) + out
              return f"\\multicolumn{{{colspan}}}{{{multicol_align}}}{{{display_val}}}"
          elif 'rowspan="' in attrs:
              if multirow_align == "naive":
                  return display_val
              rowspan = attrs[attrs.find('rowspan="') + 9 :]
              rowspan = int(rowspan[: rowspan.find('"')])
              return f"\\multirow[{multirow_align}]{{{rowspan}}}{{*}}{{{display_val}}}"
      if wrap:
          return f"{{{display_val}}}"
      else:
          return display_val
  
imports: from __future__ import annotations
  from collections import defaultdict
  from functools import partial
  import re
  from typing import Any, Callable, DefaultDict, Dict, List, Optional, Sequence, Tuple, TypedDict, Union
  from uuid import uuid4
  import numpy
  from pandas._config import get_option
  from pandas._libs import lib
  from pandas._typing import Axis, Level
  from pandas.compat._optional import import_optional_dependency
  from pandas.core.dtypes.common import is_complex, is_float, is_integer
  from pandas.core.dtypes.generic import ABCSeries
  from pandas import DataFrame, Index, IndexSlice, MultiIndex, Series, isna
  from pandas.api.types import is_list_like
  import pandas.core.common
  from markupsafe import escape
label_desc: Use image node_id 17 for calling a global function with example usage: _parse_latex_header_span(cell, multirow_align, multicol_align, wrap, convert_css) and returns: str, display_val, str, display_val, str, colspan, str, multicol_align, str, display_val, str, unknown, str, multirow_align, str, rowspan, str, display_val, str, unknown, display_val