code: def rdate_to_gyear(rdate):
      r"""Convert RDate format to Gregorian year.
  
      Parameters
      ----------
      rdate : int
          RDate date format.
  
      Returns
      -------
      gyear : int
          Gregorian year.
      """
  
      d0 = rdate - 1
      n400 = math.floor(d0 / 146097)
      d1 = d0 % 146097
      n100 = math.floor(d1 / 36524)
      d2 = d1 % 36524
      n4 = math.floor(d2 / 1461)
      d3 = d2 % 1461
      n1 = math.floor(d3 / 365)
  
      theyear = 400 * n400 + 100 * n100 + 4 * n4 + n1
      if n100 == 4 or n1 == 4:
          gyear = theyear
      else:
          gyear = theyear + 1
      return gyear
  
imports: import calendar
  import logging
  import math
  import pandas
label_desc: Use image node_id 25 for calling a global function with example usage: rdate_to_gyear(rdate) and returns: gyear