INNER CODE UNIT · Python
one_hot
lucidrains/vector-quantize-pytorch · vector_quantize_pytorch/binary_mapper.py:180
one_hot = one_hot + soft_G - soft_G.detach()
# inverse pack
one_hot = inverse_pack_lead_dims(one_hot)
indices = inverse_pack_lead_dims(indices, '*')
# returning
if not return_indices:
return one_hot, aux_kl_loss
# also allow for returning indices, even though it can be derived from sparse output with an argmax
return one_hot, indices, aux_kl_loss
# allow for quick copy paste