code: def make_fitness(function, greater_is_better):
      
      if not isinstance(greater_is_better, bool):
          raise ValueError('greater_is_better must be bool, got %s'
                           % type(greater_is_better))
      if function.__code__.co_argcount != 3:
          raise ValueError('function requires 3 arguments (y, y_pred, w),'
                           ' got %d.' % function.__code__.co_argcount)
      if not isinstance(function(np.array([1, 1]),
                        np.array([2, 2]),
                        np.array([1, 1])), numbers.Number):
          raise ValueError('function must return a numeric.')
  
      return _Fitness(function, greater_is_better)
docs: Make a fitness measure, a metric scoring the quality of a program's fit.
  
      This factory function creates a fitness measure object which measures the
      quality of a program's fit and thus its likelihood to undergo genetic
      operations into the next generation. The resulting object is able to be
      called with NumPy vectorized arguments and return a resulting floating
      point score quantifying the quality of the program's representation of the
      true relationship.
  
      Parameters
      ----------
      function : callable
          A function with signature function(y, y_pred, sample_weight) that
          returns a floating point number. Where `y` is the input target y
          vector, `y_pred` is the predicted values from the genetic program, and
          sample_weight is the sample_weight vector.
  
      greater_is_better : bool
          Whether a higher value from `function` indicates a better fit. In
          general this would be False for metrics indicating the magnitude of
          the error, and True for metrics indicating the quality of fit.