code: def _idx2dt(idx, dates, tz):
      if isinstance(idx, datetime.date):
          return idx
  
      ldates = len(dates)
  
      idx = int(round(idx))
      if idx >= ldates:
          idx = ldates - 1
      if idx < 0:
          idx = 0
  
      return num2date(dates[idx], tz)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import datetime
  import warnings
  from matplotlib.dates import AutoDateLocator
  from matplotlib.dates import RRuleLocator
  from matplotlib.dates import AutoDateFormatter
  from matplotlib.dates import HOURS_PER_DAY, MIN_PER_HOUR, SEC_PER_MIN, MONTHS_PER_YEAR, DAYS_PER_WEEK, SEC_PER_HOUR, SEC_PER_DAY, num2date, rrulewrapper, YearLocator, MicrosecondLocator
  from dateutil.relativedelta import relativedelta
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _idx2dt(idx, dates, tz) and returns: num2date, idx