code: def independence_day(gyear, observed):
      r"""Get Independence Day for a given year.
  
      Parameters
      ----------
      gyear : int
          Gregorian year.
      observed : bool
          False if the exact date, True if the weekday.
  
      Returns
      -------
      d4j : int
          Independence Day in RDate format.
      """
      d4j = gdate_to_rdate(gyear, 7, 4)
      if observed:
          if day_of_week(d4j) == 6:
              d4j -= 1
          if day_of_week(d4j) == 0:
              d4j += 1
      return d4j
  
imports: import calendar
  import logging
  import math
  import pandas
label_desc: Use image node_id 39 for calling a global function with example usage: independence_day(gyear, observed) and returns: d4j