<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def subshell(shell_cls, *commands, **kwargs):
 """Decorate a function to conditionally launch a _ShellBase subshell. Arguments: shell_cls: A subclass of _ShellBase to be launched. commands: Names of command that should trigger this function object. kwargs: The keyword arguments for the command decorator method. Interface of methods decorated by this decorator method: @command(SomeShellClass, 'foo', 'bar') def bar(self, cmd, args):
 '''The command 'foo' invokes this method then launches the subshell. Arguments: cmd: A string, the name of the command that triggered this function. This is useful for knowing which command, in this case, 'foo' or 'bar', triggered this method. args: The list of arguments passed along with the command. Returns: There are three categories of valid return values. None, False, or anything that evaluates to False: The subshell is not invoked. This is useful for making a command conditionally launch a subshell. String: A string will appended to the prompt string to uniquely identify the subshell. A 2-tuple of type (string, dict):
 The string will be appended to the prompt string. The dictionary stores the data passed to the subshell. These data are the context of the subshell. The parent shell must conform to the subhshell class in terms of which key-value pairs to pass to the subshell. ''' pass """

    def decorated_func(f):
        def inner_func(self, cmd, args):
            retval = f(self, cmd, args)
            # Do not launch the subshell if the return value is None.
            if not retval:
                return
            # Pass the context (see the doc string) to the subshell if the
            # return value is a 2-tuple. Otherwise, the context is just an empty
            # dictionary.
            if isinstance(retval, tuple):
                prompt, context = retval
            else:
                prompt = retval
                context = {}
            return self.launch_subshell(shell_cls, cmd, args,
                    prompt = prompt, context = context)
        inner_func.__name__ = f.__name__
        inner_func.__doc__ = f.__doc__
        obj = command(*commands, **kwargs)(inner_func) if commands else inner_func
        obj.__launch_subshell__ = shell_cls
        return obj
    return decorated_func