Thanks for your reply. But, I would like to use the feature of enc(output)  for metric learning loss. Due to output already containing the gradient from encoder, I would like to ignore the computing gradient while passing the encoder for the second time.
input -> enc -> features -> dec -> outputs -> enc (not computing graident) -> features