generate UWidget reference from SWidget ?

TSharedPtr wid = FSlateApplication::Get().GetKeyboardFocusedWidget();

basically, i am trying to pass wid reference to blueprint . so that i can check if a specific widget is in focus or not.

how to do that?

To answer your question directly. SWidgets are decorated with metadata that describes them. The metadata I found useful for determining the UWidget source is FReflectionMetaData. The way I did this is as follows.

TSharedPtr<SWidget> Widget = FSlateApplication::Get().GetKeyboardFocusedWidget();

TSharedPtr<FReflectionMetaData> metadata = Widget->GetMetaData<FReflectionMetaData>();

if(metadata.IsValid() && metadata->SourceObject.IsValid())
{
	return  metadata->SourceObject.Get();
}

Also see https://api.unrealengine.com/INT/API/Runtime/SlateCore/Types/FReflectionMetaData/index.html

Beware, this metadata is not available for shipping builds.

This is an important detail. You should not be using this solution if you intend to ship your project.

If you already do stuff in C++ then why not simply make Blueprint Callable function that does the check in C++ why blueprint need to do that? You can get pointer to SWidget from UWidget so you can make UWidget as argument and see if SWidget pointer match.