class_docstr: A class representing an array, which could have arbitrary dimensions.
  A batch of these arrays are padded to the max dimension length in the batch
  for each dimension.
code: def as_tensor(self, padding_lengths, cuda_device=-1):
      max_shape = [
          padding_lengths["dimension_{}".format(i)]
          for i in range(len(padding_lengths))
      ]
  
      return_array = (
          numpy.ones(max_shape, "float32") * self.padding_value
      )
  
      # If the tensor has a different shape from the largest tensor, pad dimensions with zeros to
      # form the right shaped list of slices for insertion into the final tensor.
      slicing_shape = list(self.array.shape)
      if len(self.array.shape) < len(max_shape):
          slicing_shape = slicing_shape + [
              0 for _ in range(len(max_shape) - len(self.array.shape))
          ]
      slices = tuple([slice(0, x) for x in slicing_shape])
      return_array[slices] = self.array
      tensor = torch.from_numpy(return_array)
      return tensor if cuda_device == -1 else tensor.cuda(cuda_device)
  
file_path: magnitude/pymagnitude/third_party/allennlp/data/fields/array_field.py
imports: from __future__ import absolute_import
  import numpy
  import torch
  from allennlp.data.fields.field import Field
label_desc: Use image node_id 3 for calling the ArrayField obj's underlying member method code with example usage: obj.as_tensor(padding_lengths, cuda_device) and returns: unknown