docstr: share parameters from tgt_layer to src_layer
  share_level:
      0: share everything
      1: share everything but different model
      2: share weight but not bias, layernorm
docstr_tok: ["share","parameters","from","tgt_layer","to","src_layer","share_level",":","0",":","share","everything","1",":","share","everything","but","different","model","2",":","share","weight","but","not","bias",",","layernorm"]
code: def set_shared_layer(cls, share_level, src_layer, tgt_layer):
      """
      share parameters from tgt_layer to src_layer
      share_level:
          0: share everything
          1: share everything but different model
          2: share weight but not bias, layernorm
      """
      if share_level == 0:
          return tgt_layer
      if isinstance(src_layer, nn.Linear):
          return tgt_layer
      if isinstance(src_layer, TransformerEncoderLayer):
          assert src_layer.embed_dim == tgt_layer.embed_dim
          assert (
              src_layer.normalize_before == tgt_layer.normalize_before
          )
          if share_level == 1:
              src_layer.fc1 = tgt_layer.fc1
              src_layer.fc2 = tgt_layer.fc2
              src_layer.self_attn = tgt_layer.self_attn
              src_layer.final_layer_norm = tgt_layer.final_layer_norm
              src_layer.self_attn_layer_norm = (
                  tgt_layer.self_attn_layer_norm
              )
              src_layer.layernorm_embedding = (
                  tgt_layer.layernorm_embedding
              )
          else:
              src_layer.fc1.weight = tgt_layer.fc1.weight
              src_layer.fc2.weight = tgt_layer.fc2.weight
              src_layer.self_attn.k_proj.weight = (
                  tgt_layer.self_attn.k_proj.weight
              )
              src_layer.self_attn.v_proj.weight = (
                  tgt_layer.self_attn.v_proj.weight
              )
              src_layer.self_attn.q_proj.weight = (
                  tgt_layer.self_attn.q_proj.weight
              )
              src_layer.self_attn.out_proj.weight = (
                  tgt_layer.self_attn.out_proj.weight
              )
      else:
          if share_level == 1:
              return tgt_layer
      return src_layer
  
imports: import logging
  from collections import namedtuple
  import torch
  import torch.nn
  from fairseq import checkpoint_utils
  from fairseq import utils
  from fairseq.models import FairseqEncoder, FairseqDecoder, FairseqEncoderDecoderModel, register_model, register_model_architecture
  from fairseq.models.fairseq_encoder import EncoderOut
  from fairseq.models.speech_to_text import TransformerDecoder, S2TTransformerEncoder
  from fairseq.models.transformer import TransformerEncoder
  from fairseq.modules import TransformerEncoderLayer, GradMultiply, LayerNorm
label_desc: Use image node_id 2 for calling the DualInputEncoder obj's underlying member method code with example usage: obj.set_shared_layer(cls, share_level, src_layer, tgt_layer) and returns: src_layer, tgt_layer, tgt_layer, tgt_layer