async def retrieve_outputs(
        self,
        inputs: Dict[str, np.array],
        output_names: List[str],
        num_predict_intermediate_outputs: Optional[int] = None,
        ignore_const_ops: bool = True,
    ) -> Dict[str, Optional[np.array]]:
        """
        Asynchronously retrieve intermediate outputs for the specified output names and inputs.

        This method inspects the model with given inputs and collects the intermediate outputs
        for the specified output names.

        Parameters
        ----------
        output_names : List[str]
            Names of intermediate outputs to retrieve.

        inputs : Dict[str, np.ndarray])
            Input data for the model.

        num_predict_intermediate_outputs : Optional[int]
            The number of intermediate outputs to retrieve in each ``MLModel`` prediction call. Defaults to None.

        ignore_const_ops : bool
            Whether to ignore constant operations. Defaults to True.

        Returns
        -------
        Dict[str, Optional[np.array]]

            A dictionary mapping output names to their corresponding numpy array values.
            If an output is not available, its value will be None.

         Examples
        --------
        .. sourcecode:: python
        
            inspector = coremltools.models.ml_program.experimental.debugging_utils.MLModelInspector(
                model
            )
            input_data = {"input_1": np.random.rand(1, 3, 224, 224).astype(np.float32)}
            # The intermediate outputs we want to retrieve
            outputs = await inspector.retrieve_outputs(
                inputs=inputs,
                output_names=["conv1_output", "relu1_output", "pool1_output"],
            )

            for output_name, output_value in outputs.items():
                print(f"Name: {output_name}")
                print(f"Output: {output_value}")
        """
        outputs = {}
        async for name, value in self.inspect(
            inputs=inputs,
            output_names=output_names,
            ignore_const_ops=ignore_const_ops,
            num_predict_intermediate_outputs=num_predict_intermediate_outputs,
        ):
            outputs[name] = value

        return outputs

        Asynchronously retrieve intermediate outputs for the specified output names and inputs.

        This method inspects the model with given inputs and collects the intermediate outputs
        for the specified output names.

        Parameters
        ----------
        output_names : List[str]
            Names of intermediate outputs to retrieve.

        inputs : Dict[str, np.ndarray])
            Input data for the model.

        num_predict_intermediate_outputs : Optional[int]
            The number of intermediate outputs to retrieve in each ``MLModel`` prediction call. Defaults to None.

        ignore_const_ops : bool
            Whether to ignore constant operations. Defaults to True.

        Returns
        -------
        Dict[str, Optional[np.array]]

            A dictionary mapping output names to their corresponding numpy array values.
            If an output is not available, its value will be None.

         Examples
        --------
        .. sourcecode:: python
        
            inspector = coremltools.models.ml_program.experimental.debugging_utils.MLModelInspector(
                model
            )
            input_data = {"input_1": np.random.rand(1, 3, 224, 224).astype(np.float32)}
            # The intermediate outputs we want to retrieve
            outputs = await inspector.retrieve_outputs(
                inputs=inputs,
                output_names=["conv1_output", "relu1_output", "pool1_output"],
            )

            for output_name, output_value in outputs.items():
                print(f"Name: {output_name}")
                print(f"Output: {output_value}")
        
coremltools/models/ml_program/experimental/debugging_utils.py