def extract_label(label):
    """Get the layer number, name and shape from a string.

    Parameters
    ----------

    label: str
        Specifies both the layer type, index and shape, e.g.
        ``'03Conv2D_3x32x32'``.

    Returns
    -------

    : tuple[int, str, tuple]
        - layer_num: The index of the layer in the network.
        - name: The type of the layer.
        - shape: The shape of the layer
    """

    label = label.split('_')
    layer_num = None
    for i in range(max(4, len(label) - 2)):
        if label[0][:i].isdigit():
            layer_num = int(label[0][:i])
    name = ''.join(s for s in label[0] if not s.isdigit())
    if name[-1] == 'D':
        name = name[:-1]
    if len(label) > 1:
        shape = tuple([int(s) for s in label[-1].split('x')])
    else:
        shape = ()
    return layer_num, name, shape