def load_hardware_labels(<EOL>session, candidate_classes, filename, attrib, annotator_name="<STR_LIT>"<EOL>):
<EOL>candidate_classes = (<EOL>candidate_classes<EOL>if isinstance(candidate_classes, (list, tuple))<EOL>else [candidate_classes]<EOL>)<EOL>ak = session.query(GoldLabelKey).filter(GoldLabelKey.name == annotator_name).first()<EOL>if ak is None:<EOL><INDENT>ak = GoldLabelKey(<EOL>name=annotator_name,<EOL>candidate_classes=[_.__tablename__ for _ in candidate_classes],<EOL>)<EOL>session.add(ak)<EOL>session.commit()<EOL><DEDENT>candidates = []<EOL>for candidate_class in candidate_classes:<EOL><INDENT>candidates.extend(session.query(candidate_class).all())<EOL><DEDENT>gold_dict = get_gold_dict(filename, attribute=attrib)<EOL>cand_total = len(candidates)<EOL>logger.info(f"<STR_LIT>")<EOL>labels = <NUM_LIT:0><EOL>cands = []<EOL>values = []<EOL>for i, c in enumerate(tqdm(candidates)):<EOL><INDENT>doc = (c[<NUM_LIT:0>].context.sentence.document.name).upper()<EOL>part = (c[<NUM_LIT:0>].context.get_span()).upper()<EOL>val = ("<STR_LIT>".join(c[<NUM_LIT:1>].context.get_span().split())).upper()<EOL>label = session.query(GoldLabel).filter(GoldLabel.candidate == c).first()<EOL>if label is None:<EOL><INDENT>if (doc, part, val) in gold_dict:<EOL><INDENT>values.append(TRUE)<EOL><DEDENT>else:<EOL><INDENT>values.append(FALSE)<EOL><DEDENT>cands.append(c)<EOL>labels += <NUM_LIT:1><EOL><DEDENT><DEDENT>session.bulk_insert_mappings(<EOL>GoldLabel,<EOL>[<EOL>{"<STR_LIT>": cand.id, "<STR_LIT>": [annotator_name], "<STR_LIT>": [val]}<EOL>for (cand, val) in zip(cands, values)<EOL>],<EOL>)<EOL>session.commit()<EOL>logger.info(f"<STR_LIT>")<EOL>
Bulk insert hardware GoldLabels.

    :param session: The database session to use.
    :param candidate_classes: Which candidate_classes to load labels for.
    :param filename: Path to the CSV file containing gold labels.
    :param attrib: Which attributes to load labels for (e.g. "stg_temp_max").