if not isinstance(llm_chain, LLMChain):
        raise ValueError(f"Expected LLMChain, got {llm_chain}")
    if "combine_document_chain" in config:
        combine_document_chain_config = config.pop("combine_document_chain")
        combine_document_chain = load_chain_from_config(combine_document_chain_config)
    elif "combine_document_chain_path" in config:
        combine_document_chain = load_chain(config.pop("combine_document_chain_path"))
    else:
        raise ValueError(
            "One of `combine_document_chain` or "
            "`combine_document_chain_path` must be present."
        )
    if "collapse_document_chain" in config:
        collapse_document_chain_config = config.pop("collapse_document_chain")
        if collapse_document_chain_config is None:
            collapse_document_chain = None
        else:
            collapse_document_chain = load_chain_from_config(
                collapse_document_chain_config
            )
    elif "collapse_document_chain_path" in config:
        collapse_document_chain = load_chain(config.pop("collapse_document_chain_path"))
    return MapReduceDocumentsChain(
        llm_chain=llm_chain,
        combine_document_chain=combine_document_chain,
        collapse_document_chain=collapse_document_chain,
        **config,
    )
def _load_llm_bash_chain(config: dict, **kwargs: Any) -> LLMBashChain:
    llm_chain = None
    if "llm_chain" in config:
        llm_chain_config = config.pop("llm_chain")
        llm_chain = load_chain_from_config(llm_chain_config)
    elif "llm_chain_path" in config:
        llm_chain = load_chain(config.pop("llm_chain_path"))
    # llm attribute is deprecated in favor of llm_chain, here to support old configs
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/chains/loading.html