code: def _render_density(
      table: alt.Data,
      *,
      x_name: str,
      levels: int,
      alpha: float,
      color_scheme: str = "tableau10",
      series_selection=None,
      selection=None,
      x_scale: alt.Scale = alt.Undefined,
      y_scale: alt.Scale = alt.Undefined,
  ) -> alt.Chart:
      areas: List[alt.Chart] = []
      for i in range(1, levels):
          y = f"v{5 - i}:Q"
          y2 = f"v{5 + i}:Q"
  
          encode = dict(
              x=alt.X("step:Q", scale=x_scale),
              y=alt.Y(y, scale=y_scale),
              y2=alt.Y2(y2),
              color=alt.Color(
                  "series:N", scale=alt.Scale(scheme=color_scheme)
              ),
          )
  
          if series_selection:
              encode["opacity"] = alt.condition(
                  series_selection,
                  alt.value(alpha**i),
                  alt.value(0.001),
              )
  
          areas.append(
              alt.Chart(table)
              .mark_area(opacity=alpha**i)
              .encode(**encode)
          )
  
      encode = dict(
          x=alt.X("step:Q", scale=x_scale, title=x_name),
          y=alt.Y("v5:Q", scale=y_scale, title="Value"),
          color=alt.Color(
              "series:N", scale=alt.Scale(scheme=color_scheme)
          ),
      )
  
      if series_selection:
          encode["opacity"] = alt.condition(
              series_selection, alt.value(1), alt.value(0.001)
          )
  
      line: alt.Chart = alt.Chart(table).mark_line().encode(**encode)
      if selection is not None:
          line = line.add_selection(selection)
  
      areas_sum = None
      for a in areas:
          if areas_sum is None:
              areas_sum = a
          else:
              areas_sum += a
  
      if areas_sum is not None:
          line = areas_sum + line
  
      if series_selection:
          line = line.add_selection(series_selection)
  
      return line
  
imports: from typing import List
  import altair
label_desc: Use image node_id 2 for calling a global function with example usage: _render_density(table) and returns: line