Usage of Engine Code in Code Plugins

Hello.

For the release of a plugin, I need to use a part of an engine code, which is private, thus I cannot derive from or call. Thus, the only option to go for this path is to duplicate those code sections and override the actual implementation to be able to extend its functionality.

For such cases, is it considered ok to copy a code chunk from the engine?

Thanks.