code: def inventory_maps(inv):
          
  
          # Initialise dicts
          revinv = {}
          rolnam = {}
          # Iterate over domain keys in inventory dict
          for d in inv:
              # Since keys seem to be duplicated, ignore those not
              # starting with 'py:'
              if d[0:3] == 'py:' and d in IntersphinxInventory.domainrole:
                  # Get role corresponding to current domain
                  r = IntersphinxInventory.domainrole[d]
                  # Initialise role-specific name lookup string
                  rolnam[r] = ''
                  # Iterate over all type names for current domain
                  for n in inv[d]:
                      # Get the url postfix string for the current
                      # domain and type name
                      p = inv[d][n][2]
                      # Allow lookup of role and object name tuple from
                      # url postfix
                      revinv[p] = (r, n)
                      # Append object name to a string for this role,
                      # allowing regex searching for partial names
                      rolnam[r] += ' ' + n + ','
          return revinv, rolnam
docs: Construct dicts facilitating information lookup in an
          inventory dict. A reversed dict allows lookup of a tuple
          specifying the sphinx cross-reference role and the name of the
          referenced type from the intersphinx inventory url postfix
          string. A role-specific name lookup string allows the set of all
          names corresponding to a specific role to be searched via regex.