code: def query_word_reprs(
      encoder_repr: Tensor, token_indices: Tensor
  ) -> Tensor:
      """
      Given an encoder_repr (B x T_1 x H) and token_indices (B x T_2) where T_2 <= T_1,
      collect embeddings from encoder_repr pertaining to indices in token_indices. In the
      context of fine-tuning pre-trained encoders on sequence labeling, our goal is to
      build token-level representations as opposed to subword-level represenatations
      for alignment with other token-level cues, such as dictionary features. Currently,
      a token representation is built by taking its first subword representation.
      """
  
      return torch.gather(
          encoder_repr,
          1,
          token_indices.unsqueeze(2).expand(
              -1, -1, encoder_repr.size(-1)
          ),
      )
  
imports: from typing import List
  import torch
  from caffe2.python import core
  from torch import Tensor
label_desc: Use image node_id 1 for calling a global function with example usage: query_word_reprs(encoder_repr, token_indices) and returns: torch