code: def _tensorize(x: Union[torch.Tensor, List[int]]) -> torch.Tensor:
      if not isinstance(x, torch.Tensor):
          return torch.tensor(x)
      return x
  
file_path: allennlp/allennlp/data/fields/transformer_text_field.py
imports: from typing import Dict, Optional, List, Any, Union
  import torch
  import torch.nn.functional
  from allennlp.data.fields.field import Field
  from allennlp.nn import util
label_desc: Use image node_id 1 for calling a global function with example usage: _tensorize(x) and returns: x, torch