docstr: Make sure we are sharing the input and output embeddings.
  Export to TorchScript can't handle parameter sharing so we
  are cloning them instead.
docstr_tok: ["Make","sure","we","are","sharing","the","input","and","output","embeddings",".","Export","to","TorchScript","ca","n't","handle","parameter","sharing","so","we","are","cloning","them","instead","."]
code: def tie_weights(self):
      """Make sure we are sharing the input and output embeddings.
      Export to TorchScript can't handle parameter sharing so we
      are cloning them instead.
      """
      if hasattr(self, "cls"):
          self.bert.mmbt.transformer._tie_or_clone_weights(
              self.cls.predictions.decoder,
              self.bert.mmbt.transformer.embeddings.word_embeddings,
          )
  
imports: import os
  from copy import deepcopy
  from dataclasses import dataclass
  from typing import Dict, Optional, Union
  import torch
  from mmf.common.registry import registry
  from mmf.models.base_model import BaseModel
  from mmf.models.interfaces.mmbt import MMBTGridHMInterface
  from mmf.modules.encoders import EncoderFactory, ImageEncoderFactory, ImageEncoderTypes, MultiModalEncoderBase, ResNet152ImageEncoder, TextEncoderFactory, TextEncoderTypes, TransformerEncoder
  from mmf.modules.hf_layers import replace_with_jit
  from mmf.utils.checkpoint import load_pretrained_model
  from mmf.utils.configuration import get_mmf_cache_dir
  from mmf.utils.modeling import get_optimizer_parameters_for_bert
  from omegaconf import DictConfig, II, OmegaConf
  from torch import nn, Tensor
label_desc: Use image node_id 2 for calling the MMBTForPreTraining obj's underlying member method code with example usage: obj.tie_weights() without return types