<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_binary_ulid(timestamp=None, monotonic=False):
 """ Generate the bytes for an ULID. :param timestamp: An optional timestamp override. If `None`, the current time is used. :type timestamp: int|float|datetime.datetime|None :param monotonic: Attempt to ensure ULIDs are monotonically increasing. Monotonic behavior is not guaranteed when used from multiple threads. :type monotonic: bool :return: Bytestring of length 16. :rtype: bytes """

    global _last_entropy, _last_timestamp
    if timestamp is None:
        timestamp = time.time()
    elif isinstance(timestamp, datetime.datetime):
        timestamp = calendar.timegm(timestamp.utctimetuple())

    ts = int(timestamp * 1000.0)
    ts_bytes = _to_binary(
        (ts >> shift) & 0xFF for shift in (40, 32, 24, 16, 8, 0)
    )
    entropy = os.urandom(10)
    if monotonic and _last_timestamp == ts and _last_entropy is not None:
        while entropy < _last_entropy:
            entropy = os.urandom(10)
    _last_entropy = entropy
    _last_timestamp = ts
    return ts_bytes + entropy