code: def _normalize_key(value):
    
    if ndb is not None and isinstance(value, (ndb.Model, ndb.Key)):
      return None
    if getattr(value, "key", None):
      return value.key()
    elif isinstance(value, basestring):
      return datastore.Key(value)
    else:
      return value
docs: Return a key from an entity, model instance, key, or key string.