code: def test_dict_comprehension_scope(self):
      def comprehension_can_access_outer_scope_variables():
          lst = ["foo", "bar", "baz"]
          return {l: len(l) for l in lst}
  
      self.checkScript(
          comprehension_can_access_outer_scope_variables, ()
      )
  
      with self.assertRaisesRegex(RuntimeError, "undefined value i"):
  
          @torch.jit.script
          def outer_scope_cannot_access_comprehension_variables():
              d = {i: chr(i + 65) for i in range(4)}
              i = i + 1
  
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 27 for calling the TestTyping obj's underlying member method code with example usage: obj.test_dict_comprehension_scope() and returns: unknown