code: def ufunc_functional_factory(name, nargin, nargout, docstring):
      
  
      assert 0 <= nargin <= 2
  
      def __init__(self, field):
          """Initialize an instance.
  
          Parameters
          ----------
          field : `Field`
              The domain of the functional.
          """
          if not isinstance(field, Field):
              raise TypeError('`field` {!r} not a `Field`'.format(space))
  
          if _is_integer_only_ufunc(name):
              raise ValueError("ufunc '{}' only defined with integral dtype"
                               "".format(name))
  
          linear = name in LINEAR_UFUNCS
          Functional.__init__(self, space=field, linear=linear)
  
      def _call(self, x):
          """Return ``self(x)``."""
          if nargin == 1:
              return getattr(np, name)(x)
          else:
              return getattr(np, name)(*x)
  
      def __repr__(self):
          """Return ``repr(self)``."""
          return '{}({!r})'.format(name, self.domain)
  
      # Create example (also functions as doctest)
  
      if nargin != 1:
          raise NotImplementedError('Currently not suppored')
  
      if nargout != 1:
          raise NotImplementedError('Currently not suppored')
  
      space = RealNumbers()
      val = 1.0
      arg = '{}'.format(val)
      with np.errstate(all='ignore'):
          result = np.float64(getattr(np, name)(val))
  
      examples_docstring = RAW_EXAMPLES_DOCSTRING.format(space=space, name=name,
                                                         arg=arg, result=result)
      full_docstring = docstring + examples_docstring
  
      attributes = {"__init__": __init__,
                    "_call": _call,
                    "gradient": property(gradient_factory(name)),
                    "__repr__": __repr__,
                    "__doc__": full_docstring}
  
      full_name = name + '_op'
  
      return type(full_name, (Functional,), attributes)
docs: Create a ufunc `Functional` from a given specification.