code: def test_as_tensor_produces_integer_targets(self):
      vocab = Vocabulary()
      vocab.add_token_to_namespace("B", namespace="*labels")
      vocab.add_token_to_namespace("I", namespace="*labels")
      vocab.add_token_to_namespace("O", namespace="*labels")
  
      tags = ["B", "I", "O", "O", "O"]
      sequence_label_field = SequenceLabelField(
          tags, self.text, label_namespace="*labels"
      )
      sequence_label_field.index(vocab)
      padding_lengths = sequence_label_field.get_padding_lengths()
      tensor = (
          sequence_label_field.as_tensor(padding_lengths)
          .detach()
          .cpu()
          .numpy()
      )
      numpy.testing.assert_array_almost_equal(
          tensor, numpy.array([0, 1, 2, 2, 2])
      )
  
imports: from collections import defaultdict
  import logging
  import pytest
  import numpy
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data import Token, Vocabulary
  from allennlp.data.fields import TextField, SequenceLabelField
  from allennlp.data.token_indexers import SingleIdTokenIndexer
label_desc: Use image node_id 5 for calling the TestSequenceLabelField obj's underlying member method code with example usage: obj.test_as_tensor_produces_integer_targets() without return types