code: def tx2genedict(gtf, keep_version=False):
      
      d = {}
      with open_gzipsafe(gtf) as in_handle:
          for line in in_handle:
              if "gene_id" not in line or "transcript_id" not in line:
                  continue
              geneid = line.split("gene_id")[1].split(" ")[1]
              geneid = _strip_non_alphanumeric(geneid)
              txid = line.split("transcript_id")[1].split(" ")[1]
              txid = _strip_non_alphanumeric(txid)
              if keep_version and "transcript_version" in line:
                  txversion = line.split("transcript_version")[1].split(" ")[1]
                  txversion = _strip_non_alphanumeric(txversion)
                  txid  += "." + txversion
              if has_transcript_version(line) and not keep_version:
                  txid = _strip_feature_version(txid)
                  geneid = _strip_feature_version(geneid)
              d[txid] = geneid
      return d
docs: produce a tx2gene dictionary from a GTF file