docs: def _get_resources_to_remove(resource, template):
      """
          Given a resource and a template being removed, identify the resource attribtes
          which can be removed.
      """
      type_ids = [tmpltype.id for tmpltype in template.templatetypes]
  
      node_attr_ids = dict([(ra.attr_id, ra) for ra in resource.attributes])
      attrs_to_remove = []
      attrs_to_keep   = []
      for nt in resource.types:
          if nt.templatetype.id in type_ids:
              for ta in nt.templatetype.typeattrs:
                  if node_attr_ids.get(ta.attr_id):
                      attrs_to_remove.append(node_attr_ids[ta.attr_id])
          else:
              for ta in nt.templatetype.typeattrs:
                  if node_attr_ids.get(ta.attr_id):
                      attrs_to_keep.append(node_attr_ids[ta.attr_id])
      #remove any of the attributes marked for deletion as they are
      #marked for keeping based on being in another type.
      final_attrs_to_remove = set(attrs_to_remove) - set(attrs_to_keep)
  
      return list(final_attrs_to_remove)