code: def scalarize(function):
      
      def decorated(self, X, *args, **kwargs):
          scalar = not isinstance(X, np.ndarray)
  
          if scalar:
              X = np.array([X])
  
          result = function(self, X, *args, **kwargs)
          if scalar:
              result = result[0]
  
          return result
  
      decorated.__doc__ = function.__doc__
      return decorated
docs: Allow methods that only accepts 1-d vectors to work with scalars.
  
      Args:
          function(callable): Function that accepts and returns vectors.
  
      Returns:
          callable: Decorated function that accepts and returns scalars.