code: def convert_fillstyle(inputstyle, mode, inputmode=None):
      
      mode = mode.lower()
      if mode not in ('mpl', 'root'):
          raise ValueError("`{0}` is not a valid `mode`".format(mode))
      if inputmode is None:
          try:
              # inputstyle is a ROOT linestyle
              inputstyle = int(inputstyle)
              inputmode = 'root'
          except (TypeError, ValueError):
              if inputstyle is None:
                  inputmode = 'mpl'
              elif inputstyle in fillstyles_text2root:
                  inputmode = 'root'
                  inputstyle = fillstyles_text2root[inputstyle]
              elif inputstyle[0] in fillstyles_mpl2root:
                  inputmode = 'mpl'
              else:
                  raise ValueError(
                      "`{0}` is not a valid `fillstyle`".format(inputstyle))
      if inputmode == 'root':
          if mode == 'root':
              return inputstyle
          if inputstyle in fillstyles_root2mpl:
              return fillstyles_root2mpl[inputstyle]
          raise ValueError(
              "`{0}` is not a valid `fillstyle`".format(inputstyle))
      else:
          if inputstyle is not None and inputstyle[0] not in fillstyles_mpl2root:
              raise ValueError(
                  "`{0}` is not a valid matplotlib `fillstyle`".format(
                      inputstyle))
          if mode == 'mpl':
              return inputstyle
          if inputstyle is None:
              return fillstyles_mpl2root[inputstyle]
          return fillstyles_mpl2root[inputstyle[0]]
docs: Convert *inputstyle* to ROOT or matplotlib format.
  
      Output format is determined by *mode* ('root' or 'mpl').  The *inputstyle*
      may be a ROOT fill style, a matplotlib hatch style, None, 'none', 'hollow',
      or 'solid'.