code: def next_tag(base_dir: str, cd_id: str) -> (str, int):
          
  
          LOGGER.debug('Tails.next_tag >>> base_dir: %s, cd_id: %s', base_dir, cd_id)
  
          if not ok_cred_def_id(cd_id):
              LOGGER.debug('Tails.next_tag <!< Bad cred def id %s', cd_id)
              raise BadIdentifier('Bad cred def id {}'.format(cd_id))
  
          tag = 1 + max([int(rev_reg_id2tag(basename(f)))
              for f in Tails.links(base_dir) if cd_id in basename(f)] + [-1])  # -1: next tag is '0' if no tags so far
          size = min(2**(tag + 6), Tails.MAX_SIZE)
  
          rv = (tag, size)
          LOGGER.debug('Tails.next_tag <<< %s', rv)
          return rv
docs: Return the next tag name available for a new rev reg id on input cred def id in base directory,
          and suggested size of associated rev reg.
  
          :param base_dir: base directory for tails files, thereafter split by cred def id
          :param cd_id: credential definition identifier of interest
          :return: stringified least non-negative integer not yet used in a rev reg id associated with a tails file
              in base directory, and recommendation for next size to use