<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _filter_valid_arguments(self, arguments, binary="mongod", config=False):
 """ Return a list of accepted arguments. Check which arguments in list are accepted by the specified binary (mongod, mongos). If an argument does not start with '-' but its preceding argument was accepted, then it is accepted as well. Example ['--slowms', '1000'] both arguments would be accepted for a mongod. """

        # get the help list of the binary
        if self.args and self.args['binarypath']:
            binary = os.path.join(self.args['binarypath'], binary)
        ret = (subprocess.Popen(['%s' % binary, '--help'],
               stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=False))

        out, err = ret.communicate()
        accepted_arguments = []
        # extract all arguments starting with a '-'
        for line in [option for option in out.decode('utf-8').split('\n')]:
            line = line.lstrip()
            if line.startswith('-'):
                argument = line.split()[0]
                # exception: don't allow unsupported config server arguments
                if config and argument in ['--oplogSize', '--storageEngine',
                                           '--smallfiles', '--nojournal']:
                    continue
                accepted_arguments.append(argument)

        # add undocumented options
        accepted_arguments.append('--setParameter')
        if binary.endswith('mongod'):
            accepted_arguments.append('--wiredTigerEngineConfigString')

        # filter valid arguments
        result = []
        for i, arg in enumerate(arguments):
            if arg.startswith('-'):
                # check if the binary accepts this argument
                # or special case -vvv for any number of v
                argname = arg.split('=', 1)[0]
                if argname in accepted_arguments or re.match(r'-v+', arg):
                    result.append(arg)
                elif (binary.endswith('mongod') and
                      argname in self.UNDOCUMENTED_MONGOD_ARGS):
                    result.append(arg)
                elif self.ignored_arguments.get(binary + argname) is None:
                    # warn once for each combination of binary and unknown arg
                    self.ignored_arguments[binary + argname] = True
                    if not (binary.endswith("mongos") and
                        arg in self.UNSUPPORTED_MONGOS_ARGS):
                        print("warning: ignoring unknown argument %s for %s" %
                            (arg, binary))
            elif i > 0 and arguments[i - 1] in result:
                # if it doesn't start with a '-', it could be the value of
                # the last argument, e.g. `--slowms 1000`
                result.append(arg)

        # return valid arguments as joined string
        return ' '.join(result)