<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def encode_max_segments_accepted(arg):
 """Encode the maximum number of segments the device will accept, Section 20.1.2.4, and if the device says it can only accept one segment it shouldn't say that it supports segmentation!"""

    # unspecified
    if not arg:
        return 0

    if arg > 64:
        return 7

    # the largest number not greater than the arg
    for i in range(6, 0, -1):
        if _max_segments_accepted_encoding[i] <= arg:
            return i

    raise ValueError("invalid max max segments accepted: %r" % (arg,))