code: def test_generator_arg(self):
      def f(generator: torch.Generator):
          tensor = torch.empty(2, 2)
          tensor.normal_(-1.0, 1.0, generator=generator)
          return tensor
  
      generator = torch.Generator()
      generator.manual_seed(2023)
  
      script_f = torch.jit.script(f, (generator,))
  
      for i in range(3):
          generator = torch.Generator()
          generator.manual_seed(2023 + i)
  
          torch.manual_seed(1 + i)
  
          eager_tensor = f(generator)
  
          generator = torch.Generator()
          generator.manual_seed(2023 + i)
  
          torch.manual_seed(1 + i)
  
          script_tensor = script_f(generator)
  
          self.assertEqual(eager_tensor, script_tensor)
  
file_path: pytorch/test/jit/test_generator.py
imports: import io
  import math
  import unittest
  import torch
  from torch.nn import init
  from torch.testing._internal.common_utils import skipIfLegacyJitExecutor
  from torch.testing._internal.jit_utils import JitTestCase
label_desc: Use image node_id 4 for calling the TestGenerator obj's underlying member method code with example usage: obj.test_generator_arg() and returns: tensor