code: def _get_env(key, default=None, coerce=lambda x: x, required=False):
      """
      Return env var coerced into a type other than string.
      This function extends the standard os.getenv function to enable
      the coercion of values into data types other than string (all env
      vars are strings by default).
      Args:
          key: string, the name of the env var to look up
      Kwargs:
          default: the default value to return if the env var does not exist. NB the
              default value is **not** coerced, and is assumed to be of the correct type.
          coerce: a function that is used to coerce the value returned into
              another type
          required: bool, if True, then a RequiredSettingMissingError error is raised
              if the env var does not exist.
      Returns the env var, passed through the coerce function
      """
      try:
          value = os.environ[key]
      except KeyError:
          if required is True:
              raise RequiredSettingMissingError(key)
          else:
              return default
  
      try:
          return coerce(value)
      except Exception:
          raise CoercionError(key, value, coerce)
  
imports: import decimal
  import json
  import os
  from dateutil import parser
label_desc: Use image node_id 1 for calling a global function with example usage: _get_env(key, default, coerce, required) and returns: coerce, default