code: def one_hot_to_tokens(one_hot):
      """
      Converts an L x D one-hot encoding into an L-vector of integers in the range
      [0, D], where the token D is used when the one-hot encoding is all 0. This
      assumes that the one-hot encoding is well-formed, with at most one 1 in each
      column (and 0s elsewhere).
      """
      tokens = np.tile(
          one_hot.shape[1], one_hot.shape[0]
      )  # Vector of all D
      seq_inds, dim_inds = np.where(one_hot)
      tokens[seq_inds] = dim_inds
      return tokens
  
imports: from __future__ import division, print_function
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: one_hot_to_tokens(one_hot) and returns: tokens