LayerIF: Estimating Layer Quality for Large Language Models using Influence Functions