I’m not sure, but the standalone PyTorch script seems to work:
from torch import Tensor
@torch.jit.script
def get_item(x: Tensor):
    item = x.item()
    return item

beam_size = torch.randn(1)
item = get_item(beam_size)
print(get_item.graph)
> graph(%x.1 : Tensor):
  %item.1 : Scalar = aten::item(%x.1) # <ipython-input-109-1655baf12d25>:4:11
  return (%item.1)
print(item)
> 0.18689797818660736