code: def period(period_value, period_unit):
      try:
          from dateutil.relativedelta import (
              relativedelta as period_impl,
          )
      except Exception:
          from datetime import timedelta as period_impl
  
      if period_unit == "nanoseconds":
          period_unit = "microseconds"
          period_value = int(period_value / 1000)
  
      arguments = dict(zip((period_unit,), (period_value,)))
  
      if period_unit == "milliseconds":
          return timedelta(**arguments)
  
      return period_impl(**arguments)
  
imports: import itertools
  import re
  import os
  import socket
  import contextlib
  import codecs
  from datetime import timedelta
  from pyparsing import Forward, Keyword, QuotedString, Word, Literal, Suppress, Regex, Optional, SkipTo, ZeroOrMore, Group, lineno, col, TokenConverter, replaceWith, alphanums, alphas8bit, ParseSyntaxException, StringEnd
  from pyparsing import ParserElement
  from .config_tree import ConfigTree, ConfigSubstitution, ConfigList, ConfigValues, ConfigUnquotedString, ConfigInclude, NoneValue, ConfigQuotedString
  from .exceptions import ConfigSubstitutionException, ConfigMissingException, ConfigException
  import logging
  import copy
label_desc: Use image node_id 1 for calling a global function with example usage: period(period_value, period_unit) and returns: period_impl, timedelta