class_docstr: A `AdjacencyField` defines directed adjacency relations between elements
  in a :class:`~allennlp.data.fields.sequence_field.SequenceField`.
  Because it's a labeling of some other field, we take that field as input here
  and use it to determine our padding and other things.
  
  This field will get converted into an array of shape (sequence_field_length, sequence_field_length),
  where the (i, j)th array element is either a binary flag indicating there is an edge from i to j,
  or an integer label k, indicating there is a label from i to j of type k.
  
  # Parameters
  
  indices : `List[Tuple[int, int]]`
  sequence_field : `SequenceField`
      A field containing the sequence that this `AdjacencyField` is labeling.  Most often,
      this is a `TextField`, for tagging edge relations between tokens in a sentence.
  labels : `List[str]`, optional, (default = `None`)
      Optional labels for the edges of the adjacency matrix.
  label_namespace : `str`, optional (default=`'labels'`)
      The namespace to use for converting tag strings into integers.  We convert tag strings to
      integers for you, and this parameter tells the `Vocabulary` object which mapping from
      strings to integers to use (so that "O" as a tag doesn't get the same id as "O" as a word).
  padding_value : `int`, optional (default = `-1`)
      The value to use as padding.
class_docstr_tok: ["A","`","AdjacencyField","`","defines","directed","adjacency","relations","between","elements","in","a",":","class",":","`","~allennlp.data.fields.sequence_field.SequenceField","`",".","Because","it","'s","a","labeling","of","some","other","field",",","we","take","that","field","as","input","here","and","use","it","to","determine","our","padding","and","other","things",".","This","field","will","get","converted","into","an","array","of","shape","(","sequence_field_length",",","sequence_field_length",")",",","where","the","(","i",",","j",")","th","array","element","is","either","a","binary","flag","indicating","there","is","an","edge","from","i","to","j",",","or","an","integer","label","k",",","indicating","there","is","a","label","from","i","to","j","of","type","k.","#","Parameters","indices",":","`","List","[","Tuple","[","int",",","int","]","]","`","sequence_field",":","`","SequenceField","`","A","field","containing","the","sequence","that","this","`","AdjacencyField","`","is","labeling",".","Most","often",",","this","is","a","`","TextField","`",",","for","tagging","edge","relations","between","tokens","in","a","sentence",".","labels",":","`","List","[","str","]","`",",","optional",",","(","default","=","`","None","`",")","Optional","labels","for","the","edges","of","the","adjacency","matrix",".","label_namespace",":","`","str","`",",","optional","(","default=","`","'labels","'","`",")","The","namespace","to","use","for","converting","tag","strings","into","integers",".","We","convert","tag","strings","to","integers","for","you",",","and","this","parameter","tells","the","`","Vocabulary","`","object","which","mapping","from","strings","to","integers","to","use","(","so","that","``","O","''","as","a","tag","does","n't","get","the","same","id","as","``","O","''","as","a","word",")",".","padding_value",":","`","int","`",",","optional","(","default","=","`","-1","`",")","The","value","to","use","as","padding","."]
code: def as_tensor(self, padding_lengths: Dict[str, int]) -> torch.Tensor:
      desired_num_tokens = padding_lengths["num_tokens"]
      tensor = (
          torch.ones(desired_num_tokens, desired_num_tokens)
          * self._padding_value
      )
      labels = self._indexed_labels or [
          1 for _ in range(len(self.indices))
      ]
  
      for index, label in zip(self.indices, labels):
          tensor[index] = label
      return tensor
  
file_path: allennlp/allennlp/data/fields/adjacency_field.py
imports: from typing import Dict, List, Set, Tuple, Optional
  import logging
  import textwrap
  import torch
  from allennlp.common.checks import ConfigurationError
  from allennlp.data.fields.field import Field
  from allennlp.data.fields.sequence_field import SequenceField
  from allennlp.data.vocabulary import Vocabulary
label_desc: Use image node_id 6 for calling the AdjacencyField obj's underlying member method code with example usage: obj.as_tensor(padding_lengths) and returns: tensor