code: def set_events(n, k, gyear, gday):
      r"""Define monthly events for a given year.
  
      Parameters
      ----------
      n : int
          Occurrence of a given day counting in either direction.
      k : int
          Day of the week.
      gyear : int
          Gregorian year for the events.
      gday : int
          Gregorian day representing the first day to consider.
  
      Returns
      -------
      events : list of RDate (int)
          Monthly events in RDate format.
  
      Example
      -------
      >>> # Options Expiration (Third Friday of every month)
      >>> set_events(3, 5, 2017, 1)
      """
  
      events = []
      month_range = range(1, 13)
      for m in month_range:
          rdate = nth_kday(n, k, gyear, m, gday)
          events.append(rdate)
      return events
  
imports: import calendar
  import logging
  import math
  import pandas
label_desc: Use image node_id 26 for calling a global function with example usage: set_events(n, k, gyear, gday) and returns: events