def create_context(repr_dict, sentence_id=None):
    '''
    :param repr_dict: a dict representing a 'line' or 'sentence' or a 'segment'
    :return: a list of context objects representing the data for each token in the sequence
    '''

    context_list = []
    # is checked before in create_contexts, but who knows
    if repr_dict not in 'target':
        print("No 'target' label in data representations")
        return []
    if 'tags' not in repr_dict:
        print("No 'tag' label in data representations or wrong format of tag")
        print(repr_dict)
        return []
#    if 'alignments' in repr_dict:
#        repr_dict['alignments'] = convert_alignments(repr_dict['alignments'], len(repr_dict['target']))

    active_keys = repr_dict.keys()
    active_keys.remove('tags')
    for idx, word in enumerate(repr_dict['target']):
        c = {}
        c['token'] = word
        c['index'] = idx
        if sentence_id is not None:
            c['sentence_id'] = sentence_id
        if type(repr_dict['tags']) == list or type(repr_dict['tags']) == np.ndarray:
            c['tag'] = repr_dict['tags'][idx]
            c['sequence_tags'] = repr_dict['tags']
        elif type(repr_dict['tags']) == int:
            c['tag'] = repr_dict['tags'][idx]
        else:
            print("Unknown type of tags representation:", type(repr_dict['tags']))
            return []
        for k in active_keys:
            c[k] = repr_dict[k]
        context_list.append(c)
    return context_list


# create context objects from a data_obj -
#     - a dictionary with representation labels as keys ('target', 'source', etc.) and
#       representations (lists of lists) as values
# output: if data_type = 'plain', one list of context objects is returned
#         if data_type = 'sequential', a list of lists of context objects is returned (list of sequences)
#         if data_type = 'token', a dict {token: <list_of_contexts>} is returned
# TODO: this function requires the 'target' and 'tag' keys, but the user may wish to specify other keys
# TODO: 'target' and 'tag' don't make sense for every task
dataset/ETHPy150Open qe-team/marmot/marmot/experiment/preprocessing_utils.py/create_context/swapped operands of `not in`