code: def previous_holiday(rdate, holidays):
      r"""Find the previous holiday before a given date.
  
      Parameters
      ----------
      rdate : int
          RDate date format.
      holidays : dict of RDate (int)
          Holidays in RDate format.
  
      Returns
      -------
      holiday : RDate (int)
          Previous holiday in RDate format.
      """
      try:
          holiday = next(
              h
              for h in sorted(holidays.values(), reverse=True)
              if h < rdate
          )
      except:
          holiday = 0
      return holiday
  
imports: import calendar
  import logging
  import math
  import pandas
label_desc: Use image node_id 23 for calling a global function with example usage: previous_holiday(rdate, holidays) and returns: holiday