code: def _build_tt_chart(titv_counts):
      """Built chart showing counts of transitions and transversions."""
      width = 150
      height = 200
  
      ti = titv_counts["Transition"]
      tv = titv_counts["Transversion"]
      # Show TiTv ratio with fallback to avoid division by 0
      titv_ratio = (
          "%.2f" % (float(ti) / tv) if tv > 0 else "%d / 0" % (ti)
      )
      title = "Biallelic Ti/Tv ratio: %s" % (titv_ratio)
  
      tt_chart = _placeholder_for_empty_chart(
          "No biallelic SNPs", width=width, height=height, title=title
      )
      tt_labels = ["Transition", "Transversion"]
      if sum([titv_counts[k] for k in titv_counts]) > 0:
          tt_data = _dict_to_dataframe(titv_counts)
          bars = (
              alt.Chart(tt_data)
              .mark_bar()
              .encode(
                  x=alt.X(
                      "label",
                      sort=tt_labels,
                      axis=alt.Axis(title=None, labelAngle=0),
                  ),
                  y=alt.Y(
                      "value", axis=alt.Axis(title="Count", format="s")
                  ),
                  tooltip=alt.Tooltip("value", format=".4s"),
                  color=alt.Color(
                      "label",
                      legend=None,
                      sort=tt_labels,
                      scale=alt.Scale(scheme="teals", domain=tt_labels),
                  ),
              )
          )
          labels = bars.mark_text(dy=-5).encode(
              text=alt.Text("value", format=".4s")
          )
          tt_chart = (bars + labels).properties(
              title=title, width=width, height=height
          )
      return tt_chart
  
imports: import io
  import json
  import os
  import altair
  import numpy
  import pandas
  import tensorflow
label_desc: Use image node_id 12 for calling a global function with example usage: _build_tt_chart(titv_counts) and returns: tt_chart