def get_layer(model, layer_name):
    """
    Get layer from model by name or index.
    :param layer_name: the name or index of layer.
    :return: layer instance extract from model.
    """
    if isinstance(layer_name, int):
        return model.layers[layer_name]
    elif isinstance(layer_name, str):
        return model.get_layer(layer_name)
    else:
        raise ValueError('The layer name should only be `int` or `str`.')