docstr: Save trained model weights.
docstr_tok: ["Save","trained","model","weights","."]
code: def save_model(self, optimizer, epoch, cfg):
      """
      Save trained model weights.
      """
      model_save_dir = os.path.join(
          cfg.CONFIG.LOG.BASE_PATH,
          cfg.CONFIG.LOG.EXP_NAME,
          cfg.CONFIG.LOG.SAVE_DIR,
      )
      if not os.path.exists(model_save_dir):
          os.makedirs(model_save_dir)
      ckpt_name = "f{}_s{}_ckpt_epoch{}.pth".format(
          cfg.CONFIG.DATA.CLIP_LEN, cfg.CONFIG.DATA.FRAME_RATE, epoch
      )
      checkpoint = os.path.join(model_save_dir, ckpt_name)
      model_states = []
      for m in self.model_list:
          state_dict = m.state_dict()
          if self.use_multi_gpu:
              new_state_dict = OrderedDict()
              for key, val in state_dict.items():
                  assert key.startswith("module.")
                  new_key = key[7:]
                  new_state_dict[new_key] = val
              model_states.append(new_state_dict)
          else:
              model_states.append(state_dict)
      state = {
          "epoch": epoch + 1,
          "state_dict": model_states,
          "best_acc1": None,
          "optimizer": optimizer.state_dict(),
      }
      torch.save(state, checkpoint)
  
imports: from collections import OrderedDict
  import os
  import numpy
  import torch
  from torch import nn
  from gluoncv.torch.utils.coot_utils import truncated_normal_fill
label_desc: Use image node_id 10 for calling the MultiModalTransformer obj's underlying member method code with example usage: obj.save_model(optimizer, epoch, cfg) without return types