docs: def _get_numdiff_hessian_element_func(objective_func, nmr_steps, step_ratio):
      """Return a function to compute one element of the Hessian matrix."""
      return SimpleCLFunction.from_string('''
          /**
           * Compute the Hessian using (possibly) multiple steps with various interpolations. 
           */ 
          void _numdiff_hessian_element(
                  void* data, local mot_float_type* x_tmp, mot_float_type f_x_input,
                  uint px, uint py, global float* initial_step, global double* derivative, 
                  global double* error, local double* scratch){
  
              const uint nmr_steps = ''' + str(nmr_steps) + ''';
              uint nmr_steps_remaining = nmr_steps;
  
              local double* scratch_ind = scratch;
              local double* steps = scratch_ind;      scratch_ind += nmr_steps; 
              local double* errors = scratch_ind;     scratch_ind += nmr_steps - 1;
              local double* steps_tmp = scratch_ind;  scratch_ind += nmr_steps;
              
              if(get_local_id(0) == 0){
                  for(int i = 0; i < nmr_steps - 1; i++){
                      errors[i] = 0;
                  }
              }
              barrier(CLK_LOCAL_MEM_FENCE);
              
              _numdiff_hessian_steps(data, x_tmp, f_x_input, px, py, steps, initial_step);
  
              if(nmr_steps_remaining > 1){
                  nmr_steps_remaining = _numdiff_hessian_richardson_extrapolation(steps); 
                  barrier(CLK_LOCAL_MEM_FENCE);
              }
              
              if(nmr_steps_remaining >= 3){
                  nmr_steps_remaining = _numdiff_wynn_extrapolation(steps, errors, nmr_steps_remaining);
                  barrier(CLK_LOCAL_MEM_FENCE);                
              }
              
              if(nmr_steps_remaining > 1){
                  _numdiff_find_best_step(steps, errors, steps_tmp, nmr_steps_remaining);
                  barrier(CLK_LOCAL_MEM_FENCE);
              }
              
              if(get_local_id(0) == 0){
                  *derivative = steps[0];
                  *error = errors[0];
              }
          }
      ''', dependencies=[
          _get_numdiff_hessian_steps_func(objective_func, nmr_steps, step_ratio),
          _get_numdiff_hessian_richardson_extrapolation_func(nmr_steps, step_ratio),
          _get_numdiff_wynn_extrapolation_func(),
          _get_numdiff_find_best_step_func()
      ])