code: def _generate_holidays(
      index: pd.DatetimeIndex,
      calendar: Dict[date, str],
      holiday_windows: dict = None,
      include_bridge_days: bool = False,
      include_weekend: bool = False,
      return_dummies: bool = True,
      return_categorical: bool = False,
      return_indicator: bool = False,
  ) -> pd.DataFrame:
      """Generate holidays.
  
      This looks up holidays in the calendar for the given time index.
  
      Parameters
      ----------
      index : pd.DatetimeIndex
          Index with time points for which to generate holidays.
      calendar : HolidayBase object or Dict[date, str]
          Calendar object from holidays package [1]_.
      include_bridge_days: bool, default=False
          If True, include bridge days. Bridge days include Monday if a holiday
          is on Tuesday and Friday if a holiday is on Thursday.
      holiday_windows : Dict[str, tuple], default=None
          Dictionary for specifying a window of days around holidays, with keys
          being holiday names and values being (n_days_before, n_days_after) tuples.
      return_dummies : bool, default=True
          Whether or not to return a dummy variable for each holiday.
      return_categorical : bool, default=False
          Whether or not to return a categorical variable with holidays
          beings categories.
      return_indicator : bool, default=False
          Whether or not to return an indicator variable equal to 1 if a time
          point is a holiday or not.
  
      Returns
      -------
      pd.DataFrame
          Dataframe with index given by input `index` and holiday columns.
  
      References
      ----------
      .. [1] https://pypi.org/project/holidays/
      """
      # Note that we currently handle bridge days and windows around holidays
      # as part of the holiday generation, it may be better placed in
      # a separate calendar module.
  
      # Define variable names and fixed values.
      categorical_column = "holiday"
      indicator_column = "is_holiday"
      no_holiday_value = "no_holiday"
  
      # Get holiday dictionary by name with
      # values being a list, since we may observe
      # holidays over multiple years.
      dates = np.unique(index.date)
      holidays_by_name = defaultdict(list)
  
      filtered_dates = [dte for dte in dates if dte in calendar]
      weekends = []
      if include_weekend:
          for dte in dates:
              if dte.weekday() in [5, 6]:
                  holidays_by_name["Weekend"].append(dte)
          weekends = holidays_by_name["Weekend"]
  
      for dte in filtered_dates:
          name = calendar[dte]
          if dte not in weekends:
              holidays_by_name[name].append(dte)
  
      # Invert dictionary so that we can later map holidays to
      # dates in the time index.
      holidays_by_date = {}
      for name, dates in holidays_by_name.items():
          for dte in dates:
              holidays_by_date[dte] = name
  
      # Add window around holidays.
      if holiday_windows is not None:
          # Iterate over holidays.
          for name, window in holiday_windows.items():
              # First, we look up the dates of the holiday.
              if name in holidays_by_name:
                  dates = holidays_by_name[name]
              else:
                  raise ValueError(
                      f"holiday: {name} not found in calendar."
                  )
  
              # For each holiday, we iterate over dates.
              for dte in dates:
                  # We then get the number of days before and after
                  # the holiday.
                  before, after = window
  
                  # Finally, we add all days within the window to the
                  # holiday, making sure that we do not overwrite
                  # already existing holidays.
                  msg = (
                      "Holiday already exists. Please make sure holiday windows "
                      "are not overlapping with other holidays."
                  )
  
                  for days in range(1, before + 1):
                      date_before = dte - datetime.timedelta(days=days)
                      if date_before not in holidays_by_date:
                          holidays_by_date[date_before] = name
                      else:
                          raise ValueError(msg)
  
                  for days in range(1, after + 1):
                      date_after = dte + datetime.timedelta(days=days)
                      if date_after not in holidays_by_date:
                          holidays_by_date[date_after] = name
                      else:
                          raise ValueError(msg)
  
      if include_bridge_days:
          # Iterate over holidays.
          for name, dates in holidays_by_name.items():
              # For each holiday, iterate over all dates.
              for dte in dates:
                  # Get the weekday of the holiday.
                  weekday = dte.weekday()
  
                  # If the holiday is on Tuesday, we add Monday as a bridge day.
                  if weekday == 1:
                      bridge_day = dte - datetime.timedelta(days=1)
  
                      # We only add bridge days if they are not holidays already.
                      if bridge_day not in holidays_by_date:
                          holidays_by_date[bridge_day] = name
  
                  # If the holiday is on Thursday, we add Friday as a bridge day.
                  if weekday == 3:
                      bridge_day = dte + datetime.timedelta(days=1)
  
                      # We only add bridge days if they are not holidays already.
                      if bridge_day not in holidays_by_date:
                          holidays_by_date[bridge_day] = name
  
      # Generate categorical variable.
      holidays = (
          index.to_series()
          .dt.date.map(holidays_by_date)
          .fillna(no_holiday_value)
          .astype("category")
          .to_frame(name=categorical_column)
          .set_index(index)
      )
  
      # Generate dummies.
      if return_dummies:
          dummies = pd.get_dummies(
              holidays,
              columns=[categorical_column],
              prefix="",
              prefix_sep="",
              dtype=int,
          )
          if no_holiday_value in dummies.columns:
              dummies = dummies.drop(columns=no_holiday_value)
          holidays = pd.concat([holidays, dummies], axis=1)
  
      # Generate indicator.
      if return_indicator:
          holidays[indicator_column] = (
              holidays[categorical_column] != no_holiday_value
          ).astype(int)
  
      # Remove categorical variable if not requested.
      if not return_categorical:
          holidays = holidays.drop(columns=categorical_column)
  
      return holidays
  
file_path: sktime/sktime/transformations/series/holiday/_holidayfeats.py
imports: import datetime
  from collections import defaultdict
  from datetime import date
  from typing import Dict
  import numpy
  import pandas
  from sktime.transformations.base import BaseTransformer
  from sktime.utils.validation._dependencies import _check_soft_dependencies
label_desc: Use image node_id 1 for calling a global function with example usage: _generate_holidays(index, calendar, holiday_windows, include_bridge_days, include_weekend, return_dummies, return_categorical, return_indicator) and returns: holidays