code: def _write_data(self, s):
      start_offset = self._index
  
      offset = self._index % LEVELDBLOG_BLOCK_LEN
      space_left = LEVELDBLOG_BLOCK_LEN - offset
      data_used = 0
      data_left = len(s)
      # logger.info("write_data: index=%d offset=%d len=%d",
      #     self._index, offset, data_left)
      if space_left < LEVELDBLOG_HEADER_LEN:
          pad = "\x00" * space_left
          self._fp.write(strtobytes(pad))
          self._index += space_left
          offset = 0
          space_left = LEVELDBLOG_BLOCK_LEN
  
      # does it fit in first (possibly partial) block?
      if data_left + LEVELDBLOG_HEADER_LEN <= space_left:
          self._write_record(s)
      else:
          # write first record (we could still be in the middle of a block,
          # but this write will end on a block boundary)
          data_room = space_left - LEVELDBLOG_HEADER_LEN
          self._write_record(s[:data_room], LEVELDBLOG_FIRST)
          data_used += data_room
          data_left -= data_room
          assert data_left, "data_left should be non-zero"
  
          # write middles (if any)
          while data_left > LEVELDBLOG_DATA_LEN:
              self._write_record(
                  s[data_used : data_used + LEVELDBLOG_DATA_LEN],
                  LEVELDBLOG_MIDDLE,
              )
              data_used += LEVELDBLOG_DATA_LEN
              data_left -= LEVELDBLOG_DATA_LEN
  
          # write last and flush the entire block to disk
          self._write_record(s[data_used:], LEVELDBLOG_LAST)
          self._fp.flush()
          os.fsync(self._fp.fileno())
          self._flush_offset = self._index
  
      return start_offset, self._index, self._flush_offset
  
imports: import logging
  import os
  import struct
  import zlib
  from typing import TYPE_CHECKING, Optional, Tuple
  import wandb
label_desc: Use image node_id 13 for calling the DataStore obj's underlying member method code with example usage: obj._write_data(s) and returns: start_offset,  self,  self