code: def check_config_mode(self, check_string=")#", pattern=r"[#\$]"):
          
          self.write_channel(self.RETURN)
          output = self.read_until_pattern(pattern=pattern)
          # Strip out (admin) so we don't get a false positive with (admin)#
          # (admin-config)# would still match.
          output = output.replace("(admin)", "")
          return check_string in output
docs: Checks if the device is in configuration mode or not.
  
          IOS-XR, unfortunately, does this:
          RP/0/RSP0/CPU0:BNG(admin)#