class_docstr: Helper class for adaptive embeddings specifying a cluster of tokens.
  
  Essentially a wrapper around a vocab embedding for the cluster with additional
  metadata so that we can apply the embedding to the actual ids and hidden
  states.
class_docstr_tok: ["Helper","class","for","adaptive","embeddings","specifying","a","cluster","of","tokens",".","Essentially","a","wrapper","around","a","vocab","embedding","for","the","cluster","with","additional","metadata","so","that","we","can","apply","the","embedding","to","the","actual","ids","and","hidden","states","."]
docstr: Computes the loss during training.
docstr_tok: ["Computes","the","loss","during","training","."]
code: def compute_loss(self, decoder, hidden, targets, context):
      """Computes the loss during training."""
      logits = self._embedding.hidden_to_logits(hidden, context=context)
      soft_targets = mtf.one_hot(
          targets - self._start_token_id,
          self._vocab_dim,
          dtype=context.activation_dtype,
      )
      loss = mtf.layers.softmax_cross_entropy_with_logits(
          logits, soft_targets, self._vocab_dim, z_loss=decoder.z_loss
      )
  
      padding_mask = mtf.layers.weights_nonzero(
          targets, dtype=context.activation_dtype
      )
  
      return mtf.reduce_sum(
          loss * padding_mask
      ) / decoder.loss_denominator(targets, context.num_microbatches)
  
imports: import math
  from typing import Dict, Sequence, Union
  import gin
  import mesh_tensorflow
  from mesh_tensorflow.transformer import transformer
  from mesh_tensorflow.transformer import vocab_embeddings
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 8 for calling the _Cluster obj's underlying member method code with example usage: obj.compute_loss(decoder, hidden, targets, context) and returns: unknown