class_docstr: A ``Field`` is some piece of a data instance that ends up as an tensor in a model (either as an
  input or an output).  Data instances are just collections of fields.
  
  Fields go through up to two steps of processing: (1) tokenized fields are converted into token
  ids, (2) fields containing token ids (or any other numeric data) are padded (if necessary) and
  converted into tensors.  The ``Field`` API has methods around both of these steps, though they
  may not be needed for some concrete ``Field`` classes - if your field doesn't have any strings
  that need indexing, you don't need to implement ``count_vocab_items`` or ``index``.  These
  methods ``pass`` by default.
  
  Once a vocabulary is computed and all fields are indexed, we will determine padding lengths,
  then intelligently batch together instances and pad them into actual tensors.
docstr: Given a set of specified padding lengths, actually pad the data in this field and return a
  torch Tensor (or a more complex data structure) of the correct shape.  We also take a
  couple of parameters that are important when constructing torch Tensors.
  
  Parameters
  ----------
  padding_lengths : ``Dict[str, int]``
      This dictionary will have the same keys that were produced in
      :func:`get_padding_lengths`.  The values specify the lengths to use when padding each
      relevant dimension, aggregated across all instances in a batch.
  cuda_device : ``int``
      If cuda_device >= 0, GPUs are available and Pytorch was compiled with CUDA support, we
      will allocate tensors on this device instead of on the CPU.
docstr_tok: ["Given","a","set","of","specified","padding","lengths",",","actually","pad","the","data","in","this","field","and","return","a","torch","Tensor","(","or","a","more","complex","data","structure",")","of","the","correct","shape",".","We","also","take","a","couple","of","parameters","that","are","important","when","constructing","torch","Tensors",".","Parameters","--","--","--","--","--","padding_lengths",":","``","Dict","[","str",",","int","]","``","This","dictionary","will","have","the","same","keys","that","were","produced","in",":","func",":","`","get_padding_lengths","`",".","The","values","specify","the","lengths","to","use","when","padding","each","relevant","dimension",",","aggregated","across","all","instances","in","a","batch",".","cuda_device",":","``","int","``","If","cuda_device",">","=","0",",","GPUs","are","available","and","Pytorch","was","compiled","with","CUDA","support",",","we","will","allocate","tensors","on","this","device","instead","of","on","the","CPU","."]
code: def as_tensor(self, padding_lengths, cuda_device=-1):
      """
      Given a set of specified padding lengths, actually pad the data in this field and return a
      torch Tensor (or a more complex data structure) of the correct shape.  We also take a
      couple of parameters that are important when constructing torch Tensors.
  
      Parameters
      ----------
      padding_lengths : ``Dict[str, int]``
          This dictionary will have the same keys that were produced in
          :func:`get_padding_lengths`.  The values specify the lengths to use when padding each
          relevant dimension, aggregated across all instances in a batch.
      cuda_device : ``int``
          If cuda_device >= 0, GPUs are available and Pytorch was compiled with CUDA support, we
          will allocate tensors on this device instead of on the CPU.
      """
      raise NotImplementedError
  
file_path: magnitude/pymagnitude/third_party/allennlp/data/fields/field.py
imports: from __future__ import absolute_import
  import torch
  from allennlp.data.vocabulary import Vocabulary
label_desc: Use image node_id 4 for calling the Field obj's underlying member method code with example usage: obj.as_tensor(padding_lengths, cuda_device) without return types