code: def test_list_type_refinement_annotation_element_mismatch(self):
      def fn():
          l: List[int] = [1, 2, "foo", 3]
          return l
  
      with self.assertRaisesRegex(
          RuntimeError,
          "List type annotation"
          r" `List\[int\]` did not match the "
          "types of the given list elements",
      ):
          torch.jit.script(fn)
  
imports: import os
  import sys
  import torch
  from torch.testing._internal.jit_utils import JitTestCase, make_global
  from torch.testing._internal.common_utils import IS_WINDOWS
  from collections import namedtuple
  from typing import List, Tuple, Dict, NamedTuple
label_desc: Use image node_id 2 for calling the TestTyping obj's underlying member method code with example usage: obj.test_list_type_refinement_annotation_element_mismatch() and returns: l