def METHOD_NAME(
    bpe_dir,
    databin_dir,
    direction, spm_vocab=SPM_VOCAB, 
    splits=['train', 'test', 'valid'],
):
    src, tgt = direction.split('-')
    try:
        shutil.rmtree(f'{databin_dir}', ignore_errors=True)
        os.mkdir(f'{databin_dir}')
    except OSError as error:
        print(error)
    cmds = [
        "fairseq-preprocess",
        f"--source-lang {src} --target-lang {tgt}",
        f"--destdir {databin_dir}/",
        f"--workers 8",
    ]
    if isinstance(spm_vocab, tuple):
        src_vocab, tgt_vocab = spm_vocab
        cmds.extend(
            [
                f"--srcdict {src_vocab}",
                f"--tgtdict {tgt_vocab}",
            ]
        )
    else:
        cmds.extend(
            [
                f"--joined-dictionary",
                f"--srcdict {spm_vocab}",
            ]
        )
    input_options = []
    if 'train' in splits and glob.glob(f"{bpe_dir}/train.bpe*"):
        input_options.append(
            f"--trainpref {bpe_dir}/train.bpe",
        )        
    if 'valid' in splits and glob.glob(f"{bpe_dir}/valid.bpe*"):
        input_options.append(f"--validpref {bpe_dir}/valid.bpe")
    if 'test' in splits and glob.glob(f"{bpe_dir}/test.bpe*"):
        input_options.append(f"--testpref {bpe_dir}/test.bpe")   
    if len(input_options) > 0:    
        cmd = " ".join(cmds + input_options)
        print(cmd)
        call(cmd)