def METHOD_NAME(rank_config, sft_config):  # noqa:  C901
    triton_host = os.environ.get("TRITON_HOST_RM")
    assert triton_host is not None, "Specify reward model in the TRITON_HOST_RM environmental variable"
    triton_url, triton_model = triton_host.split("/")
    client = client_util.InferenceServerClient(url=triton_url, verbose=False)
    rank_tokenizer = transformers.AutoTokenizer.from_pretrained(rank_config.model_name, cache_dir=rank_config.cache_dir)
    sft_tokenizer = transformers.AutoTokenizer.from_pretrained(sft_config.model_name, cache_dir=sft_config.cache_dir)
    def reward_fn(samples, prompts, outputs):
        if len(samples) == 0:
            return []
        # hack to allo for different tokenizers with different eos tokens ... rest of the
        samples = [x.replace(sft_tokenizer.eos_token, rank_tokenizer.eos_token) for x in samples]
        samples = [x.replace(sft_tokenizer.pad_token, rank_tokenizer.pad_token) for x in samples]
        inputs = rank_tokenizer(samples, return_tensors="np", padding=True)
        mbs = rank_config.batch_size
        out = []
        for i in range(math.ceil(len(samples) / mbs)):
            batch_ixs = slice(i * mbs, (i + 1) * mbs)
            # We specified int32 as types for a triton client
            result = client.infer(
                triton_model,
                [
                    prepare_tensor("input_ids", inputs.input_ids[batch_ixs].astype(np.int32)),
                    prepare_tensor("attention_mask", inputs.attention_mask[batch_ixs].astype(np.int32)),
                ],
            )
            rewards = result.as_numpy("rewards")
            out.extend(rewards)
        return out
    return reward_fn