code: def extend(dset, array, **attrs):
      
      length = len(dset)
      if len(array) == 0:
          return length
      newlength = length + len(array)
      if array.dtype.name == 'object':  # vlen array
          shape = (newlength,) + preshape(array[0])
      else:
          shape = (newlength,) + array.shape[1:]
      dset.resize(shape)
      dset[length:newlength] = array
      for key, val in attrs.items():
          dset.attrs[key] = val
      return newlength
docs: Extend an extensible dataset with an array of a compatible dtype.
  
      :param dset: an h5py dataset
      :param array: an array of length L
      :returns: the total length of the dataset (i.e. initial length + L)