code: def convert_linestyle(inputstyle, mode, inputmode=None):
      
      mode = mode.lower()
      if mode not in ('mpl', 'root'):
          raise ValueError(
              "`{0}` is not a valid `mode`".format(mode))
      try:
          inputstyle = int(inputstyle)
          if inputstyle < 1:
              inputstyle = 1
      except (TypeError, ValueError):
          pass
      if inputmode is None:
          if inputstyle in linestyles_root2mpl:
              inputmode = 'root'
          elif inputstyle in linestyles_mpl2root:
              inputmode = 'mpl'
          elif inputstyle in linestyles_text2root:
              inputmode = 'root'
              inputstyle = linestyles_text2root[inputstyle]
          else:
              raise ValueError(
                  "`{0}` is not a valid `linestyle`".format(
                      inputstyle))
      if inputmode == 'root':
          if inputstyle not in linestyles_root2mpl:
              raise ValueError(
                  "`{0}` is not a valid ROOT `linestyle`".format(
                      inputstyle))
          if mode == 'root':
              return inputstyle
          return linestyles_root2mpl[inputstyle]
      else:
          if inputstyle not in linestyles_mpl2root:
              raise ValueError(
                  "`{0}` is not a valid matplotlib `linestyle`".format(
                      inputstyle))
          if mode == 'mpl':
              return inputstyle
          return linestyles_mpl2root[inputstyle]
docs: Convert *inputstyle* to ROOT or matplotlib format.
  
      Output format is determined by *mode* ('root' or 'mpl').  The *inputstyle*
      may be a ROOT line style, a matplotlib line style, or a description
      such as 'solid' or 'dotted'.