def get_trained_model(is_reverse_model=False, reverse_model=None, fetch_from_s3=True):
    """
    Get a trained model, direct or reverse.
    :param is_reverse_model: boolean, if True, a reverse trained model will be returned to be used during inference
    in direct model in *_reranking modes; if False, a direct trained model is returned
    :param reverse_model: object of a reverse model to be used in direct model in *_reranking inference modes
    :param fetch_from_s3: boolean, if True, download trained model from Amazon S3 if the the model is not found locally;
    if False, the model presence will be checked only locally
    :return:
    """
    if fetch_from_s3:
        resolver_factory = get_s3_model_resolver(S3_MODELS_BUCKET_NAME, S3_NN_MODEL_REMOTE_DIR)
    else:
        resolver_factory = None

    w2v_model_id = get_w2v_model_id() if USE_PRETRAINED_W2V_EMBEDDINGS_LAYER else None

    model = InferenceCakeChatModel(
        index_to_token=_get_index_to_token(fetch_from_s3),
        index_to_condition=_get_index_to_condition(fetch_from_s3),
        training_data_param=ModelParam(value=None, id=TRAIN_CORPUS_NAME),
        validation_data_param=ModelParam(value=None, id=get_validation_data_id(get_validation_sets_names())),
        w2v_model_param=ModelParam(value=None, id=w2v_model_id),
        model_resolver=resolver_factory,
        is_reverse_model=is_reverse_model,
        reverse_model=reverse_model)

    model.init_model()
    model.resolve_model()
    return model

    Get a trained model, direct or reverse.
    :param is_reverse_model: boolean, if True, a reverse trained model will be returned to be used during inference
    in direct model in *_reranking modes; if False, a direct trained model is returned
    :param reverse_model: object of a reverse model to be used in direct model in *_reranking inference modes
    :param fetch_from_s3: boolean, if True, download trained model from Amazon S3 if the the model is not found locally;
    if False, the model presence will be checked only locally
    :return:
    
cakechat/dialog_model/factory.py