code: def _checkMode(mode):
      
  
      if not isinstance(mode, str):
          raise TypeError('The {0} should be a string. Given: {1!r}'.format("mode", mode))
  
      if mode not in [MODE_RTU, MODE_ASCII]:
          raise ValueError("Unreconized Modbus mode given. Must be 'rtu' or 'ascii' but {0!r} was given.".format(mode))
docs: Check that the Modbus mode is valie.
  
      Args:
          mode (string): The Modbus mode (MODE_RTU or MODE_ASCII)
  
      Raises:
          TypeError, ValueError