code: def _normalize_entity(value):
    
    if ndb is not None and isinstance(value, ndb.Model):
      return None
    if getattr(value, "_populate_internal_entity", None):
      return value._populate_internal_entity()
    return value
docs: Return an entity from an entity or model instance.