code: def safe_version(module, attr="__version__", *others):
      if not isinstance(attr, list):
          attr = [attr]
      try:
          return reduce(getattr, [module] + attr)
      except AttributeError:
          if others:
              return safe_version(module, others[0], *others[1:])
          return "Cannot detect version"
  
imports: from functools import reduce
  import sys
  from os.path import dirname
label_desc: Use image node_id 1 for calling a global function with example usage: safe_version(module, attr) and returns: reduce, str, safe_version