) -> Output:
        final = None
        async for output in self.astream(input, config, **kwargs):
            if final is None:
                final = output
            else:
                final = final + output
        return cast(Output, final)
[docs]class RunnableLambda(Runnable[Input, Output]):
    """RunnableLambda converts a python callable into a Runnable.
    Wrapping a callable in a RunnableLambda makes the callable usable
    within either a sync or async context.
    RunnableLambda can be composed as any other Runnable and provides
    seamless integration with LangChain tracing.
    Examples:
        .. code-block:: python
            # This is a RunnableLambda
            from langchain_core.runnables import RunnableLambda
            def add_one(x: int) -> int:
                return x + 1
            runnable = RunnableLambda(add_one)
            runnable.invoke(1) # returns 2
            runnable.batch([1, 2, 3]) # returns [2, 3, 4]
            # Async is supported by default by delegating to the sync implementation
            await runnable.ainvoke(1) # returns 2
            await runnable.abatch([1, 2, 3]) # returns [2, 3, 4]
            # Alternatively, can provide both synd and sync implementations
            async def add_one_async(x: int) -> int:
                return x + 1
            runnable = RunnableLambda(add_one, afunc=add_one_async)
            runnable.invoke(1) # Uses add_one
            await runnable.ainvoke(1) # Uses add_one_async
    """
[docs]    def __init__(
        self,
        func: Union[
            Union[
                Callable[[Input], Output],
                Callable[[Input, RunnableConfig], Output],