import torch


def get_spec_dic(props):
    """
    Find the indices of geoms in the dataset that correspond
    to each species.
    Args:
        props (dict): dataset properties
    Returns:
        spec_dic (dict): dictionary of the form
                {smiles: idx}, where smiles is the smiles
                of a species without cis/trans indicators,
                and idx are the indices of geoms in that
                species in the dataset.
    """

    spec_dic = {}
    for i, spec in enumerate(props["smiles"]):
        no_stereo_spec = (spec.replace("\\", "")
                          .replace("/", ""))
        if no_stereo_spec not in spec_dic:
            spec_dic[no_stereo_spec] = []
        spec_dic[no_stereo_spec].append(i)

    for key, val in spec_dic.items():
        spec_dic[key] = torch.LongTensor(val)

    return spec_dic