def record_get_field_instances(rec, tag="<STR_LIT>", ind1="<STR_LIT:U+0020>", ind2="<STR_LIT:U+0020>"):
if not rec:<EOL><INDENT>return []<EOL><DEDENT>if not tag:<EOL><INDENT>return list(rec.items())<EOL><DEDENT>else:<EOL><INDENT>out = []<EOL>ind1, ind2 = _wash_indicators(ind1, ind2)<EOL>if '<STR_LIT:%>' in tag:<EOL><INDENT>for field_tag in rec:<EOL><INDENT>if _tag_matches_pattern(field_tag, tag):<EOL><INDENT>for possible_field_instance in rec[field_tag]:<EOL><INDENT>if (ind1 in ('<STR_LIT:%>', possible_field_instance[<NUM_LIT:1>]) and<EOL>ind2 in ('<STR_LIT:%>', possible_field_instance[<NUM_LIT:2>])):<EOL><INDENT>out.append(possible_field_instance)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for possible_field_instance in rec.get(tag, []):<EOL><INDENT>if (ind1 in ('<STR_LIT:%>', possible_field_instance[<NUM_LIT:1>]) and<EOL>ind2 in ('<STR_LIT:%>', possible_field_instance[<NUM_LIT:2>])):<EOL><INDENT>out.append(possible_field_instance)<EOL><DEDENT><DEDENT><DEDENT>return out<EOL><DEDENT>
Return the list of field instances for the specified tag and indications.

Return empty list if not found.
If tag is empty string, returns all fields

Parameters (tag, ind1, ind2) can contain wildcard %.

:param rec: a record structure as returned by create_record()
:param tag: a 3 characters long string
:param ind1: a 1 character long string
:param ind2: a 1 character long string
:param code: a 1 character long string
:return: a list of field tuples (Subfields, ind1, ind2, value,
         field_position_global) where subfields is list of (code, value)