Hi,
To handle such things I usually do the following pseudo code:

cond = bath_data.is_empty? (gives a Tensor of size (n_batch,) containing 0/1)

out_true = your_non_empty_code(batch_data) # Compute everything as if non-empty

out_false = self.empty_value.expand_as(out_true) # Your param for the empty ones

res = out_true * (1 - cond) + out_false * cond