class_docstr: A suite of tests for profile directed typing in TorchScript.
class_docstr_tok: ["A","suite","of","tests","for","profile","directed","typing","in","TorchScript","."]
code: def test_nested_list_and_tuple(self):
      def test_nested_list(inp):
          return [sum(v) for v in inp]
  
      def test_nested_tuple(inp):
          ans = 0.0
          for tup in inp:
              for val in tup:
                  if val > 0:
                      ans *= val
          return ans
  
      make_global(test_nested_list, test_nested_tuple)
  
      list_inp = [
          [
              1,
              2,
              3,
          ],
          [
              5,
              6,
              7,
          ],
      ]
      scripted_fn = torch.jit.script(
          test_nested_list,
          example_inputs=[
              (list_inp,),
          ],
      )
      inp = [
          [
              0,
              4,
              7,
          ],
          [
              8,
              11,
          ],
          [
              6,
              -1,
              -20,
          ],
      ]
      self.assertEqual(
          scripted_fn(
              inp,
          ),
          test_nested_list(
              inp,
          ),
      )
  
      list_inp = (
          [
              1,
              2,
              3,
          ],
          [
              5,
              6,
              7,
          ],
      )
      scripted_fn = torch.jit.script(
          test_nested_list,
          example_inputs=[
              (list_inp,),
          ],
      )
      inp = (
          [
              0,
              4,
              7,
          ],
          [
              8,
              11,
          ],
          [
              6,
              -1,
              -20,
          ],
      )
      self.assertEqual(
          scripted_fn(
              inp,
          ),
          test_nested_list(
              inp,
          ),
      )
  
      tup_inp = [
          (
              1.0,
              2.6,
              3.7,
          ),
          (
              5.7,
              6.1,
              1.7,
          ),
      ]
      scripted_fn = torch.jit.script(
          test_nested_tuple,
          example_inputs=[
              (tup_inp,),
          ],
      )
      inp = [
          (
              1.0,
              4.1,
              7.4,
          ),
          (
              4.8,
              1.1,
              -1.2,
          ),
          (
              6.3,
              -1.3,
              -2.0,
          ),
      ]
      self.assertEqual(
          scripted_fn(
              inp,
          ),
          test_nested_tuple(
              inp,
          ),
      )
  
      tup_inp = (
          (
              True,
              False,
              True,
          ),
          (
              False,
              False,
              False,
          ),
      )
      scripted_fn = torch.jit.script(
          test_nested_tuple,
          example_inputs=[
              (tup_inp,),
          ],
      )
      inp = (
          (
              True,
              True,
              True,
          ),
          (
              False,
              False,
              True,
          ),
      )
      self.assertEqual(
          scripted_fn(
              inp,
          ),
          test_nested_tuple(
              inp,
          ),
      )
  
imports: import os
  import sys
  import torch
  from torch.testing._internal.jit_utils import JitTestCase, make_global
  from torch.jit._monkeytype_config import _IS_MONKEYTYPE_INSTALLED
  from typing import List, Dict, Tuple, Any, Optional, NamedTuple
  from torch.testing._internal.common_utils import NoTest
label_desc: Use image node_id 11 for calling the TestPDT obj's underlying member method code with example usage: obj.test_nested_list_and_tuple() and returns: unknown, ans