class_docstr: In PyText DocNN models we need a way to access word embedding layers,
  generate the embeddings and subtract the baseline.
  To do so, we separate embedding layers from the model, compute the embeddings
  separately and do all operations needed outside of the model.
  The original embedding layer is being replaced by `PyTextInterpretableEmbedding`
  layer which passes precomputed embedding vectors to lower layers.
class_docstr_tok: ["In","PyText","DocNN","models","we","need","a","way","to","access","word","embedding","layers",",","generate","the","embeddings","and","subtract","the","baseline",".","To","do","so",",","we","separate","embedding","layers","from","the","model",",","compute","the","embeddings","separately","and","do","all","operations","needed","outside","of","the","model",".","The","original","embedding","layer","is","being","replaced","by","`","PyTextInterpretableEmbedding","`","layer","which","passes","precomputed","embedding","vectors","to","lower","layers","."]
docstr: After attribution scores are computed for an input embedding vector
  we need to split it up into attribution sub tensors for each
  feature type: word, dict and other types
  
  TODO: we can potentally also output tuples of attributions. This might be
  a better option. We'll work on this in a separate diff.
  
  Args
  
     attributions: A tensor that contains attribution values for each input
                   field. It usually has the same dimensions as the input
                   tensor
  
  Return
  
     attribution_map: A dictionary of feature_type and attribution values
docstr_tok: ["After","attribution","scores","are","computed","for","an","input","embedding","vector","we","need","to","split","it","up","into","attribution","sub","tensors","for","each","feature","type",":","word",",","dict","and","other","types","TODO",":","we","can","potentally","also","output","tuples","of","attributions",".","This","might","be","a","better","option",".","We","'ll","work","on","this","in","a","separate","diff",".","Args","attributions",":","A","tensor","that","contains","attribution","values","for","each","input","field",".","It","usually","has","the","same","dimensions","as","the","input","tensor","Return","attribution_map",":","A","dictionary","of","feature_type","and","attribution","values"]
code: def get_attribution_map(self, attributions):
      r"""
      After attribution scores are computed for an input embedding vector
      we need to split it up into attribution sub tensors for each
      feature type: word, dict and other types
  
      TODO: we can potentally also output tuples of attributions. This might be
      a better option. We'll work on this in a separate diff.
  
      Args
  
         attributions: A tensor that contains attribution values for each input
                       field. It usually has the same dimensions as the input
                       tensor
  
      Return
  
         attribution_map: A dictionary of feature_type and attribution values
  
      """
      begin = 0
      attribution_map = defaultdict()
      for embedding, embedding_size in zip(
          self.embeddings, self.embedding_dims
      ):
          end = begin + embedding_size
          if isinstance(embedding, WordEmbedding):
              attribution_map["word"] = attributions[:, :, begin:end]
          elif isinstance(embedding, DictEmbedding):
              attribution_map["dict"] = attributions[:, :, begin:end]
          else:
              raise NotImplementedError(
                  "Currently only word and dict "
                  "embeddings are supported"
              )
          begin = end
  
      return attribution_map
  
imports: from collections import defaultdict
  import torch
  from pytext.models.embeddings.dict_embedding import DictEmbedding
  from pytext.models.embeddings.word_embedding import WordEmbedding
  from pytext.models.model import EmbeddingBase, EmbeddingList
label_desc: Use image node_id 3 for calling the PyTextInterpretableEmbedding obj's underlying member method code with example usage: obj.get_attribution_map(attributions) and returns: attribution_map