code: def embeddings(args: argparse.Namespace):
      logger.info("Arguments: %s", args)
  
      sockeye_model, source_vocabs, target_vocabs = model.load_model(
          args.model,
          checkpoint=args.checkpoint,
          device=pt.device("cpu"),
      )
      sockeye_model.eval()
  
      if args.side == "source":
          vocab = source_vocabs[0]
      else:
          vocab = target_vocabs[0]
      vocab_inv = reverse_vocab(vocab)
  
      if args.side == "source":
          weights = sockeye_model.embedding_source.embedding.weight.data
      else:
          weights = sockeye_model.embedding_target.embedding.weight.data
      logger.info("Embedding size: %d", weights.shape[1])
  
      logger.info("Computing pairwise similarities...")
      sims = compute_sims(weights, args.norm)
  
      # weights (vocab, num_target_embed)
      check_condition(
          weights.shape[0] == len(vocab),
          "vocab and embeddings matrix do not match: %d vs. %d"
          % (weights.shape[0], len(vocab)),
      )
  
      logger.info("Reading from STDin...")
      for line in sys.stdin:
          tokens = list(utils.get_tokens(line))
          if not tokens:
              continue
          print("Input:", line.rstrip())
          ids = tokens2ids(tokens, vocab)
          for token, token_id in zip(tokens, ids):
              token = C.UNK_SYMBOL if token_id == C.UNK_ID else token
              print("%s id=%d" % (token, token_id))
              neighbours = nearest_k(sims, token_id, args.k, args.gamma)
              for i, (neighbour_id, score) in enumerate(neighbours, 1):
                  print(
                      "  %s id=%d sim=%.4f"
                      % (vocab_inv[neighbour_id], neighbour_id, score)
                  )
          print()
  
file_path: sockeye/sockeye/embeddings.py
imports: import argparse
  import logging
  import sys
  from typing import Iterable, Tuple
  import torch
  import sockeye.constants
  from .None import model
  from .None import utils
  from .data_io import tokens2ids
  from .log import setup_main_logger
  from .utils import check_condition
  from .vocab import reverse_vocab
label_desc: Use image node_id 4 for calling a global function with example usage: embeddings(args) without return types