Tagging by specified family types/element/category

I wanted to know if it is possible to have a script that adds tags to elements? Similar to the tag all but can now get specific to what elements.
For example, if I have communication devices (A and B), I’d like for it to only tag devices that are A. I have been googling and looking on YouTube but I don’t see much on this. Any advice?

look here for create method

as far as tagging only specific families, you just need to pass a list of elements that’s filtered to include only the families you want to tag and set xyz position for the tag

for element in elements:
	element_ref = Reference(element)
	IndependentTag.Create(doc, doc.ActiveView.Id, element_ref, False, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Horizontal, XYZ(X, Y, Z))