def send(
        self,
        request: _JSONRPCRequest,
        resource_path: _Optional[_Path] = None,
    ) -> None:
        """
        Send a JSON-RPC request to the device application.

        This method prepares and sends a JSON-RPC request, optionally including a resource file.

        Parameters
        ----------
        request: JSONRPCRequest
           The JSON-RPC request to send.

        resource_path: Optional[Path]
           Path to a resource file to be sent with the request.

        Returns
        -------
        DataTransferInfo
           Information about the data transfer.
        """
        message = {}
        message["jsonrpc"] = "2.0"
        message["id"] = request.id
        message["method"] = request.method
        message["params"] = request.params

        requests_directory = self.requests_directory / request.id
        if requests_directory.is_dir():
            _shutil.rmtree(requests_directory.resolve())

        if resource_path is not None:
            resource_name = _os.path.basename(resource_path)
            self.device.session.send_file_to_app(
                resource_path,
                destination=f"{self.source}/requests/resources/{request.id}/{resource_name}",
            )
            message["resource"] = resource_name

        requests_directory.mkdir(parents=True, exist_ok=False)
        message_json_file = requests_directory / "message.json"
        with open(message_json_file, "w") as file:
            json_string = _json.dumps(message)
            file.write(json_string)

        self.device.session.send_file_to_app(
            message_json_file,
            destination=f"{self.source}/requests/messages/{request.id}/message.json",
        )

        Send a JSON-RPC request to the device application.

        This method prepares and sends a JSON-RPC request, optionally including a resource file.

        Parameters
        ----------
        request: JSONRPCRequest
           The JSON-RPC request to send.

        resource_path: Optional[Path]
           Path to a resource file to be sent with the request.

        Returns
        -------
        DataTransferInfo
           Information about the data transfer.
        
coremltools/models/ml_program/experimental/remote_device.py