def get_tensor_size(ts, bs=None):
    """Return the size of tensor in bytes.
    The first unknown dimension of a tensor will be filled by `bs`.
    The other unknown dimenstions of a tensor will be filled by a default
    value.
    """
    d, s = 1, 1  # `d` default value for i-th unknown dimension (i != 0)
    ndims = ts.shape.ndims
    if ndims is None:
        return d
    for i in range(0, ndims):
        v = ts.shape[i].value
        if v is None:
            if i == 0:
                v = bs if bs is not None else d
            else:
                v = d
        s *= v
    return s*(ts.dtype.size)