code: def test_param_invariants(self, tensor_cls, tensor_requires_grad):
      x = self._create_tensor(tensor_cls).requires_grad_(
          tensor_requires_grad
      )
      param = nn.Parameter(x, requires_grad=(not tensor_requires_grad))
  
      self.assertIsInstance(param, nn.Parameter)
      # Ensure requires_grad passed to Parameter's constructor takes precedence.
      self.assertEqual(param.requires_grad, not tensor_requires_grad)
  
      # Ensure original tensor is not mutated by Parameter construction.
      self.assertNotIsInstance(x, nn.Parameter)
      self.assertEqual(x.requires_grad, tensor_requires_grad)
  
imports: import tempfile
  from copy import deepcopy
  from functools import partial
  from unittest import expectedFailure
  import torch
  from torch import nn
  from torch.nn.modules.lazy import LazyModuleMixin
  from torch.nn.utils.parametrize import register_parametrization, remove_parametrizations
  from torch.testing._internal.common_subclass import DiagTensorBelow, subclass_db
  from torch.testing._internal.common_utils import TestCase, instantiate_parametrized_tests, parametrize, run_tests, skipIfTorchDynamo, subtest
  from torch.testing._internal.logging_tensor import LoggingTensor
  from torch.utils._pytree import tree_map
label_desc: Use image node_id 2 for calling the TestSubclass obj's underlying member method code with example usage: obj.test_param_invariants(tensor_cls, tensor_requires_grad) without return types