class_docstr: Simple implementation of the starspace algorithm: https://arxiv.org/abs/1709.03856.
docstr: Add command-line arguments specifically for this agent.
docstr_tok: ["Add","command-line","arguments","specifically","for","this","agent","."]
code: def add_cmdline_args(
      cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
  ) -> ParlaiParser:
      """
      Add command-line arguments specifically for this agent.
      """
      agent = parser.add_argument_group("StarSpace Arguments")
      agent.add_argument(
          "-emb",
          "--embedding-type",
          default="random",
          choices=[
              "random",
              "glove",
              "glove-fixed",
              "fasttext",
              "fasttext-fixed",
              "fasttext_cc",
              "fasttext_cc-fixed",
          ],
          help="Choose between different strategies for initializing word "
          "embeddings. Default is random, but can also preinitialize "
          "from Glove or Fasttext. Preinitialized embeddings can also "
          "be fixed so they are not updated during training.",
      )
      agent.add_argument(
          "-esz",
          "--embeddingsize",
          type=int,
          default=128,
          help="size of the token embeddings",
      )
      agent.add_argument(
          "-enorm",
          "--embeddingnorm",
          type=float,
          default=10,
          help="max norm of word embeddings",
      )
      agent.add_argument(
          "-shareEmb",
          "--share-embeddings",
          type="bool",
          default=True,
          help="whether LHS and RHS share embeddings",
      )
      agent.add_argument(
          "--lins",
          default=0,
          type=int,
          help="If set to 1, add a linear layer between lhs and rhs.",
      )
      agent.add_argument(
          "-lr",
          "--learningrate",
          type=float,
          default=0.1,
          help="learning rate",
      )
      agent.add_argument(
          "-margin", "--margin", type=float, default=0.1, help="margin"
      )
      agent.add_argument(
          "--input_dropout",
          type=float,
          default=0,
          help="fraction of input/output features to dropout during training",
      )
      agent.add_argument(
          "-opt",
          "--optimizer",
          default="sgd",
          choices=StarspaceAgent.OPTIM_OPTS.keys(),
          help="Choose between pytorch optimizers. "
          "Any member of torch.optim is valid and will "
          "be used with default params except learning "
          "rate (as specified by -lr).",
      )
      agent.add_argument(
          "-tr",
          "--truncate",
          type=int,
          default=-1,
          help="truncate input & output lengths to speed up "
          "training (may reduce accuracy). This fixes all "
          "input and output to have a maximum length.",
      )
      agent.add_argument(
          "-k",
          "--neg-samples",
          type=int,
          default=10,
          help="number k of negative samples per example",
      )
      agent.add_argument(
          "--parrot-neg",
          type=int,
          default=0,
          help="include query as a negative",
      )
      agent.add_argument(
          "--tfidf",
          type="bool",
          default=False,
          help="Use frequency based normalization for embeddings.",
      )
      agent.add_argument(
          "-cs",
          "--cache-size",
          type=int,
          default=1000,
          help="size of negative sample cache to draw from",
      )
      agent.add_argument(
          "-hist",
          "--history-length",
          default=10000,
          type=int,
          help="Number of past tokens to remember. ",
      )
      agent.add_argument(
          "-histr",
          "--history-replies",
          default="label_else_model",
          type=str,
          choices=["none", "model", "label", "label_else_model"],
          help="Keep replies in the history, or not.",
      )
      agent.add_argument(
          "-fixedCands",
          "--fixed-candidates-file",
          default=None,
          type=str,
          help="File of cands to use for prediction",
      )
      cls.dictionary_class().add_cmdline_args(
          parser, partial_opt=partial_opt
      )
      return parser
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.core.agents import Agent
  from parlai.core.dict import DictionaryAgent
  from parlai.utils.misc import maintain_dialog_history, load_cands
  from parlai.core.torch_agent import TorchAgent
  from parlai.utils.io import PathManager
  import parlai.utils.torch
  import parlai.utils.logging
  from .modules import Starspace
  import torch
  from torch import optim
  import torch.nn
  from collections import deque
  import copy
  import random
  import json
label_desc: Use image node_id 2 for calling the StarspaceAgent obj's underlying member method code with example usage: obj.add_cmdline_args(cls, parser, partial_opt) and returns: parser