code: def parse_wrap_facets(facets: str | list[str]) -> list[str]:
      """
      Return list of facetting variables
      """
      valid_forms = ["~ var1", "~ var1 + var2"]
      error_msg = (
          "Valid formula for 'facet_wrap' look like" f" {valid_forms}"
      )
  
      if isinstance(facets, (list, tuple)):
          return facets
  
      if not isinstance(facets, str):
          raise PlotnineError(error_msg)
  
      if "~" in facets:
          variables_pattern = r"(\w+(?:\s*\+\s*\w+)*|\.)"
          pattern = rf"\s*~\s*{variables_pattern}\s*"
          match = re.match(pattern, facets)
          if not match:
              raise PlotnineError(error_msg)
  
          facets = [var.strip() for var in match.group(1).split("+")]
      elif re.match(r"\w+", facets):
          # allow plain string as the variable name
          facets = [facets]
      else:
          raise PlotnineError(error_msg)
  
      return facets
  
file_path: plotnine/plotnine/facets/facet_wrap.py
imports: from __future__ import annotations
  import re
  import typing
  from warnings import warn
  import numpy
  import pandas
  from .._utils import join_keys, match
  from ..exceptions import PlotnineError, PlotnineWarning
  from .facet import add_missing_facets, combine_vars, eval_facet_vars, facet, layout_null
  from .strips import Strips, strip
label_desc: Use image node_id 2 for calling a global function with example usage: parse_wrap_facets(facets) and returns: facets, facets