def from_spec_or_path(
        spec_or_path: Union["proto.Model_pb2.Model", str],
        weights_dir: str,
        compute_units: ComputeUnit = ComputeUnit.ALL,
        function_name: Optional[str] = None,
        optimization_hints: Optional[Dict[str, Any]] = None,
        device: Device = None,
    ) -> "MLModelAsyncWrapper":
        """
        Creates an MLModelAsyncWrapper instance from a model specification or model path.

        This static method constructs an ``MLModelAsyncWrapper`` object based on the provided
        model specification and additional parameters.

        If the device parameter is ``None``, the model is loaded on the local system. Otherwise, it
        is loaded on the specified device.

        Parameters
        ----------
        spec_or_path : Union["proto.Model_pb2.Model", str]
            Either a protobuf specification of the model (``proto.Model_pb2.Model``) or a string
            representing the file path to the model (``mlpackage``).

        weights_dir: str
            The model weights directory.

        function_name : Optional[str]
            The function name. Defaults to the model's function name.

        compute_units : coremltools.ComputeUnit:
            The compute units to use. Defaults to the model's compute unit.

        optimization_hints : Optional[Dict[str, Any]]
            Keys are the names of the optimization hint, either 'reshapeFrequency' or 'specializationStrategy'.
            Values are enumeration values of type ``coremltools.ReshapeFrequency`` or ``coremltools.SpecializationStrategy``.

        device: Device
            The device on which the model will execute.

        Returns
        -------
        MLModelAsyncWrapper
            An instance of MLModelAsyncWrapper.
        """
        if device is None:
            return LocalMLModelAsyncWrapper(
                spec_or_path=spec_or_path,
                weights_dir=weights_dir,
                compute_units=compute_units,
                function_name=function_name,
                optimization_hints=optimization_hints,
            )
        else:
            return RemoteMLModelAsyncWrapper(
                spec_or_path=spec_or_path,
                weights_dir=weights_dir,
                compute_units=compute_units,
                function_name=function_name,
                optimization_hints=optimization_hints,
                device=device,
            )

        Creates an MLModelAsyncWrapper instance from a model specification or model path.

        This static method constructs an ``MLModelAsyncWrapper`` object based on the provided
        model specification and additional parameters.

        If the device parameter is ``None``, the model is loaded on the local system. Otherwise, it
        is loaded on the specified device.

        Parameters
        ----------
        spec_or_path : Union["proto.Model_pb2.Model", str]
            Either a protobuf specification of the model (``proto.Model_pb2.Model``) or a string
            representing the file path to the model (``mlpackage``).

        weights_dir: str
            The model weights directory.

        function_name : Optional[str]
            The function name. Defaults to the model's function name.

        compute_units : coremltools.ComputeUnit:
            The compute units to use. Defaults to the model's compute unit.

        optimization_hints : Optional[Dict[str, Any]]
            Keys are the names of the optimization hint, either 'reshapeFrequency' or 'specializationStrategy'.
            Values are enumeration values of type ``coremltools.ReshapeFrequency`` or ``coremltools.SpecializationStrategy``.

        device: Device
            The device on which the model will execute.

        Returns
        -------
        MLModelAsyncWrapper
            An instance of MLModelAsyncWrapper.
        
coremltools/models/ml_program/experimental/async_wrapper.py