'Retrieves a layer based on either its name (unique) or index.
Indices are based on order of horizontal graph traversal (bottom-up).
# Arguments
name: String, name of layer.
index: Integer, index of layer.
# Returns
A layer instance.
# Raises
ValueError: In case of invalid layer name or index.'

def get_layer(self, name=None, index=None):

    if (index is not None):
        if (len(self.layers) <= index):
            raise ValueError((((('Was    asked    to    retrieve    layer    at    index    ' + str(index)) + '    but    model    only    has    ') + str(len(self.layers))) + '    layers.'))
        else:
            return self.layers[index]
    elif (not name):
        raise ValueError('Provide    either    a    layer    name    or    layer    index.')
    layer = None
    for layer in self.layers:
        if (layer.name == name):
            return layer
    if (not layer):
        raise ValueError(('No    such    layer:    ' + name))
