<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def construct_chunk(cls, chunk_type, payload, encoding='utf-8'):
 """Construct and return a single chunk."""

    if isinstance(payload, str):
      payload = payload.encode(encoding)
    elif not isinstance(payload, bytes):
      raise TypeError('cannot encode type: {}'.format(type(payload)))

    header = struct.pack(cls.HEADER_FMT, len(payload), chunk_type)
    return header + payload