docs: def _predictResponseSize(mode, functioncode, payloadToSlave):
      """Calculate the number of bytes that should be received from the slave.
  
      Args:
       * mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII)
       * functioncode (int): Modbus function code.
       * payloadToSlave (str): The raw request that is to be sent to the slave (not hex encoded string)
  
      Returns:
          The preducted number of bytes (int) in the response.
  
      Raises:
          ValueError, TypeError.
  
      """
      MIN_PAYLOAD_LENGTH = 4  # For implemented functioncodes here
      BYTERANGE_FOR_GIVEN_SIZE = slice(2, 4)  # Within the payload
  
      NUMBER_OF_PAYLOAD_BYTES_IN_WRITE_CONFIRMATION = 4
      NUMBER_OF_PAYLOAD_BYTES_FOR_BYTECOUNTFIELD = 1
  
      RTU_TO_ASCII_PAYLOAD_FACTOR = 2
  
      NUMBER_OF_RTU_RESPONSE_STARTBYTES   = 2
      NUMBER_OF_RTU_RESPONSE_ENDBYTES     = 2
      NUMBER_OF_ASCII_RESPONSE_STARTBYTES = 5
      NUMBER_OF_ASCII_RESPONSE_ENDBYTES   = 4
  
      # Argument validity testing
      _checkMode(mode)
      _checkFunctioncode(functioncode, None)
      _checkString(payloadToSlave, description='payload', minlength=MIN_PAYLOAD_LENGTH)
  
      # Calculate payload size
      if functioncode in [5, 6, 15, 16]:
          response_payload_size = NUMBER_OF_PAYLOAD_BYTES_IN_WRITE_CONFIRMATION
  
      elif functioncode in [1, 2, 3, 4]:
          given_size = _twoByteStringToNum(payloadToSlave[BYTERANGE_FOR_GIVEN_SIZE])
          if functioncode == 1 or functioncode == 2:
              # Algorithm from MODBUS APPLICATION PROTOCOL SPECIFICATION V1.1b
              number_of_inputs = given_size
              response_payload_size = NUMBER_OF_PAYLOAD_BYTES_FOR_BYTECOUNTFIELD + \
                                      number_of_inputs // 8 + (1 if number_of_inputs % 8 else 0)
  
          elif functioncode == 3 or functioncode == 4:
              number_of_registers = given_size
              response_payload_size = NUMBER_OF_PAYLOAD_BYTES_FOR_BYTECOUNTFIELD + \
                                      number_of_registers * _NUMBER_OF_BYTES_PER_REGISTER
  
      else:
          raise ValueError('Wrong functioncode: {}. The payload is: {!r}'.format( \
              functioncode, payloadToSlave))
  
      # Calculate number of bytes to read
      if mode == MODE_ASCII:
          return NUMBER_OF_ASCII_RESPONSE_STARTBYTES + \
              response_payload_size * RTU_TO_ASCII_PAYLOAD_FACTOR + \
              NUMBER_OF_ASCII_RESPONSE_ENDBYTES
      else:
          return NUMBER_OF_RTU_RESPONSE_STARTBYTES + \
              response_payload_size + \
              NUMBER_OF_RTU_RESPONSE_ENDBYTES