Black Hole Entropy Function and the Attractor Mechanism in Higher Derivative Gravity