code: def validate(*a, **kw):
      
      RETURNS_KEY = '__return__'
  
      def validate_schema_decorator(func):
  
          returns_defined = False
          returns = None
  
          schema_args_dict = _args_to_dict(func, a)
          schema_arguments = _merge_args_with_kwargs(schema_args_dict, kw)
  
          if RETURNS_KEY in schema_arguments:
              returns_defined = True
              returns = schema_arguments[RETURNS_KEY]
              del schema_arguments[RETURNS_KEY]
  
          input_schema = (Schema(schema_arguments, extra=ALLOW_EXTRA)
                          if len(schema_arguments) != 0 else lambda x: x)
          output_schema = Schema(returns) if returns_defined else lambda x: x
  
          @wraps(func)
          def func_wrapper(*args, **kwargs):
              args_dict = _args_to_dict(func, args)
              arguments = _merge_args_with_kwargs(args_dict, kwargs)
              validated_arguments = input_schema(arguments)
              output = func(**validated_arguments)
              return output_schema(output)
  
          return func_wrapper
  
      return validate_schema_decorator
docs: Decorator for validating arguments of a function against a given schema.
  
      Set restrictions for arguments:
  
          >>> @validate(arg1=int, arg2=int)
          ... def foo(arg1, arg2):
          ...   return arg1 * arg2
  
      Set restriction for returned value:
  
          >>> @validate(arg=int, __return__=int)
          ... def bar(arg1):
          ...   return arg1 * 2