driver.isKeyboardShown() function is sometimes returning false even when keyboard is getting displayed

I have encountered a rare issue in which isKeyboardShown() method returns ‘false’ even when the keyboard is displayed. Please fix this issue. I have encountered this issue 2/100 times.
Adding logs for your reference.

[HTTP] --> POST /session/3b2252d9-6224-475d-82f7-2c8c2b3fbf8a/execute/sync
[HTTP] {"args":[],"script":"mobile: isKeyboardShown"}
[AndroidUiautomator2Driver@2d2f (3b2252d9)] Calling AppiumDriver.execute() with args: ["mobile: isKeyboardShown",[],"3b2252d9-6224-475d-82f7-2c8c2b3fbf8a"]
[AndroidUiautomator2Driver@2d2f (3b2252d9)] Executing method 'mobile: isKeyboardShown'
[ADB] Running '/Users/aadityaawasthi/Library/Android/sdk/platform-tools/adb -P 5037 -s TCGYKVYDZ5RCGI9H shell dumpsys input_method'
[AndroidUiautomator2Driver@2d2f (3b2252d9)] Responding to client with driver.execute() result: false
[HTTP] <-- POST /session/3b2252d9-6224-475d-82f7-2c8c2b3fbf8a/execute/sync 200 735 ms - 15