docstr: Test to ensure RNN packed sequences are modified correctly.
docstr_tok: ["Test","to","ensure","RNN","packed","sequences","are","modified","correctly","."]
code: def test_packed_sequence(self):
      """Test to ensure RNN packed sequences are modified correctly."""
      rnn = nn.RNN(5, 5)
  
      x = torch.rand((5, 1, 5), dtype=torch.float)
      seq_length = torch.tensor([4], dtype=torch.int)
  
      def fill_fn(x):
          x.fill_(0)
  
      x = nn.utils.rnn.pack_padded_sequence(x, seq_length)
      x, h = rnn(x)
      x = _apply_to_tensors(fill_fn, x)
      x, _ = nn.utils.rnn.pad_packed_sequence(x)
      self.assertEqual(torch.sum(x), 0)
  
file_path: pytorch/test/distributed/fsdp/test_utils.py
imports: import random
  import sys
  import unittest
  from collections import OrderedDict
  from dataclasses import dataclass
  from typing import List
  import torch
  import torch.nn
  from torch import distributed
  from torch.distributed.utils import _apply_to_tensors, _replace_by_prefix
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, parametrize, run_tests, subtest, TEST_WITH_DEV_DBG_ASAN, TestCase
label_desc: Use image node_id 3 for calling the TestUtils obj's underlying member method code with example usage: obj.test_packed_sequence() without return types