class_docstr: This class tests the functionality of `Union`.
  
  Note: It's important to be able to refine the type of a `Union` to
  one of its internal types. Currently, there are differences in the
  way Python expects `isinstance` checks and the way TorchScript
  expects `isinstance` checks. This means that we can't use
  `checkScript` in our test cases because either the eager mode or the
  script mode wouldn't run! So, some test cases have separate but
  equivalent functions to emulate `checkScript`.
class_docstr_tok: ["This","class","tests","the","functionality","of","`","Union","`",".","Note",":","It","'s","important","to","be","able","to","refine","the","type","of","a","`","Union","`","to","one","of","its","internal","types",".","Currently",",","there","are","differences","in","the","way","Python","expects","`","isinstance","`","checks","and","the","way","TorchScript","expects","`","isinstance","`","checks",".","This","means","that","we","ca","n't","use","`","checkScript","`","in","our","test","cases","because","either","the","eager","mode","or","the","script","mode","would","n't","run","!","So",",","some","test","cases","have","separate","but","equivalent","functions","to","emulate","`","checkScript","`","."]
code: def test_union_variable_can_be_reassigned(self):
      @torch.jit.script
      def aux1(i: int):
          return int(i**2)
  
      @torch.jit.script
      def aux2(s: str):
          return s + s
  
      def fn() -> Union[int, str]:
          x: Union[int, str] = "foo"
          i: int = 1
          x = i
          y: int = aux1(x)
          z: str = aux2(str(y))
          x = z
          return x
  
      self.checkScript(fn, ())
  
imports: import io
  import os
  import sys
  import torch
  from torch.testing import FileCheck
  from enum import Enum
  from textwrap import dedent
  from typing import Dict, List, Optional, Tuple, Union
  from torch.testing._internal.jit_utils import JitTestCase, make_global
label_desc: Use image node_id 11 for calling the TestUnion obj's underlying member method code with example usage: obj.test_union_variable_can_be_reassigned() and returns: int, unknown, x