import copy


def pair_from_inputs(inputs, b=0):
    """Return a pair without the batch dimension.
    Note that b specifies which batch index to use.
    Also note that inputs has a nested dictionary structure 2 layers deep.
    """
    pair = {}
    for key, value in inputs.items():
        if isinstance(value, dict):
            pair[key] = {}
            for key2, value2 in value.items():
                pair[key][key2] = copy.deepcopy(value2[b])
        else:
            pair[key] = copy.deepcopy(value[b])
    return pair