code: def week_start_date(
      col: Column, week_start_day: str = "Sun"
  ) -> Column:
      """Function takes a Spark `Column` and an optional `week_start_day` argument and returns a `Column` with the corresponding start of week dates.
  
      The "standard week" in Spark starts on Sunday, however an optional argument can be
      used to start the week from a different day, e.g. Monday. The `week_start_day`
      argument is a string corresponding to the day of the week to start the week
      from, e.g. `"Mon"`, `"Tue"`, and must be in the set: `{"Sun", "Mon", "Tue", "Wed",
      "Thu", "Fri", "Sat"}`. If the argument given is not a valid day then a `ValueError`
      will be raised.
  
      :param col: The column to determine start of week dates on
      :type col: Column
      :param week_start_day: The day to start the week on
      :type week_start_day: str
      :returns: A Column with start of week dates
      :rtype: Column
      """
      _raise_if_invalid_day(week_start_day)
      # the "standard week" in Spark is from Sunday to Saturday
      mapping = {
          "Sun": "Sat",
          "Mon": "Sun",
          "Tue": "Mon",
          "Wed": "Tue",
          "Thu": "Wed",
          "Fri": "Thu",
          "Sat": "Fri",
      }
      end = week_end_date(col, mapping[week_start_day])
      return F.date_add(end, -6)
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING
  import re
  import uuid
  from typing import Any
  import pyspark.sql.functions
  from pyspark.sql.types import ArrayType, BooleanType, StringType
label_desc: Use image node_id 8 for calling a global function with example usage: week_start_date(col, week_start_day) and returns: F