code: def parse(
      self,
      datetime_string: str,
      fmt: Union[List[str], str],
      normalize_whitespace: bool = False,
  ) -> datetime:
      if normalize_whitespace:
          datetime_string = re.sub(r"\s+", " ", datetime_string)
  
      if isinstance(fmt, list):
          return self._parse_multiformat(datetime_string, fmt)
  
      try:
          fmt_tokens: List[_FORMAT_TYPE]
          fmt_pattern_re: Pattern[str]
          fmt_tokens, fmt_pattern_re = self._generate_pattern_re(fmt)
      except re.error as e:
          raise ParserMatchError(
              f"Failed to generate regular expression pattern: {e}."
          )
  
      match = fmt_pattern_re.search(datetime_string)
  
      if match is None:
          raise ParserMatchError(
              f"Failed to match {fmt!r} when parsing {datetime_string!r}."
          )
  
      parts: _Parts = {}
      for token in fmt_tokens:
          value: Union[Tuple[str, str, str], str]
          if token == "Do":
              value = match.group("value")
          elif token == "W":
              value = (
                  match.group("year"),
                  match.group("week"),
                  match.group("day"),
              )
          else:
              value = match.group(token)
  
          if value is None:
              raise ParserMatchError(
                  f"Unable to find a match group for the specified token {token!r}."
              )
  
          self._parse_token(token, value, parts)  # type: ignore[arg-type]
  
      return self._build_datetime(parts)
  
imports: import re
  import sys
  from datetime import datetime, timedelta
  from datetime import tzinfo
  from functools import lru_cache
  from typing import Any, ClassVar, Dict, Iterable, List, Match, Optional, Pattern, SupportsFloat, SupportsInt, Tuple, Union, cast, overload
  from dateutil import tz
  from arrow import locales
  from arrow.constants import DEFAULT_LOCALE
  from arrow.util import next_weekday, normalize_timestamp
label_desc: Use image node_id 3 for calling the DateTimeParser obj's underlying member method code with example usage: obj.parse(datetime_string, fmt, normalize_whitespace) and returns: self, self