class_docstr: A GRU copying decoder that accepts an variable-sized set of encodings.
class_docstr_tok: ["A","GRU","copying","decoder","that","accepts","an","variable-sized","set","of","encodings","."]
code: def tensorize(self, datapoint: DecoderData) -> TokenizedOutput:
      max_seq_len = self.max_seq_len
      target_with_start_end = (
          [self.START] + datapoint.target_data + [self.END]
      )
      target_with_start_end = target_with_start_end[:max_seq_len]
  
      seq_len = min(len(target_with_start_end), max_seq_len)
  
      return TokenizedOutput(
          token_ids=self.__output_vocabulary.get_id_or_unk_multiple(
              target_with_start_end
          ),
          length=seq_len,
          num_input_elements=len(datapoint.input_elements),
          # Which elements can be copied at this step?
          copyable_elements=[
              np.array(
                  [
                      i
                      for i, input_element in enumerate(
                          datapoint.input_elements
                      )
                      if input_element == target_token
                  ],
                  dtype=np.int32,
              )
              for target_token in target_with_start_end[1:]
          ],
      )
  
imports: from typing_extensions import Final
  import logging
  import math
  import numpy
  import torch
  import torch.nn
  from dpu_utils.mlutils import Vocabulary
  from torch_scatter import scatter_add
  from torch_scatter.composite import scatter_log_softmax, scatter_logsumexp
  from typing import Any, Counter, Dict, List, NamedTuple, Tuple, Union
  from ptgnn.baseneuralmodel import AbstractNeuralModel
label_desc: Use image node_id 8 for calling the GruCopyingDecoderModel obj's underlying member method code with example usage: obj.tensorize(datapoint) and returns: TokenizedOutput