code: def _get_canonical_map(self):
          
          cacheattr = "_token2canonical"
          if not hasattr(self, cacheattr):
              # Get the list of commands and their aliases, if any.
              token2canonical = {}
              cmd2funcname = {}  # use a dict to strip duplicates
              for attr in self.get_names():
                  if attr.startswith("do_"): cmdname = attr[3:]
                  elif attr.startswith("_do_"): cmdname = attr[4:]
                  else:
                      continue
                  cmd2funcname[cmdname] = attr
                  token2canonical[cmdname] = cmdname
              for cmdname, funcname in cmd2funcname.items():  # add aliases
                  func = getattr(self, funcname)
                  aliases = getattr(func, "aliases", [])
                  for alias in aliases:
                      if alias in cmd2funcname:
                          import warnings
                          warnings.warn("'%s' alias for '%s' command conflicts "
                                        "with '%s' handler" %
                                        (alias, cmdname, cmd2funcname[alias]))
                          continue
                      token2canonical[alias] = cmdname
              setattr(self, cacheattr, token2canonical)
          return getattr(self, cacheattr)
docs: Return a mapping of available command names and aliases to
          their canonical command name.