code: def create_and_check_encoder_decoder_shared_weights(
      self,
      config,
      input_ids,
      decoder_input_ids,
      attention_mask,
      decoder_attention_mask,
      lm_labels,
  ):
      for model_class in [Pop2PianoForConditionalGeneration]:
          torch.manual_seed(0)
          model = model_class(config=config).to(torch_device).eval()
          # load state dict copies weights but does not tie them
          model.encoder.load_state_dict(
              model.decoder.state_dict(), strict=False
          )
  
          torch.manual_seed(0)
          tied_config = copy.deepcopy(config)
          tied_config.tie_encoder_decoder = True
          tied_model = (
              model_class(config=tied_config).to(torch_device).eval()
          )
  
          model_result = model(
              input_ids=input_ids,
              decoder_input_ids=decoder_input_ids,
              attention_mask=attention_mask,
              decoder_attention_mask=decoder_attention_mask,
          )
  
          tied_model_result = tied_model(
              input_ids=input_ids,
              decoder_input_ids=decoder_input_ids,
              attention_mask=attention_mask,
              decoder_attention_mask=decoder_attention_mask,
          )
  
          # check that models has less parameters
          self.parent.assertLess(
              sum(p.numel() for p in tied_model.parameters()),
              sum(p.numel() for p in model.parameters()),
          )
          random_slice_idx = ids_tensor(
              (1,), model_result[0].shape[-1]
          ).item()
  
          # check that outputs are equal
          self.parent.assertTrue(
              torch.allclose(
                  model_result[0][0, :, random_slice_idx],
                  tied_model_result[0][0, :, random_slice_idx],
                  atol=1e-4,
              )
          )
  
          # check that outputs after saving and loading are equal
          with tempfile.TemporaryDirectory() as tmpdirname:
              tied_model.save_pretrained(tmpdirname)
              tied_model = model_class.from_pretrained(tmpdirname)
              tied_model.to(torch_device)
              tied_model.eval()
  
              # check that models has less parameters
              self.parent.assertLess(
                  sum(p.numel() for p in tied_model.parameters()),
                  sum(p.numel() for p in model.parameters()),
              )
              random_slice_idx = ids_tensor(
                  (1,), model_result[0].shape[-1]
              ).item()
  
              tied_model_result = tied_model(
                  input_ids=input_ids,
                  decoder_input_ids=decoder_input_ids,
                  attention_mask=attention_mask,
                  decoder_attention_mask=decoder_attention_mask,
              )
  
              # check that outputs are equal
              self.parent.assertTrue(
                  torch.allclose(
                      model_result[0][0, :, random_slice_idx],
                      tied_model_result[0][0, :, random_slice_idx],
                      atol=1e-4,
                  )
              )
  
imports: import copy
  import tempfile
  import unittest
  import numpy
  from datasets import load_dataset
  from transformers import Pop2PianoConfig
  from transformers.feature_extraction_utils import BatchFeature
  from transformers.testing_utils import require_essentia, require_librosa, require_onnx, require_scipy, require_torch, slow, torch_device
  from transformers.utils import is_essentia_available, is_librosa_available, is_scipy_available, is_torch_available
  from ...generation.test_utils import GenerationTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 13 for calling the Pop2PianoModelTester obj's underlying member method code with example usage: obj.create_and_check_encoder_decoder_shared_weights(config, input_ids, decoder_input_ids, attention_mask, decoder_attention_mask, lm_labels) without return types