code: def transfer_function(
      level=[0.1, 0.5, 0.9], opacity=[0.01, 0.05, 0.1], level_width=0.1, controls=True, max_opacity=0.2
  ):
      
      tf_kwargs = {}
      # level, opacity and widths can be scalars
      try:
          level[0]
      except:
          level = [level]
      try:
          opacity[0]
      except:
          opacity = [opacity] * 3
      try:
          level_width[0]
      except:
          level_width = [level_width] * 3
          # clip off lists
      min_length = min(len(level), len(level_width), len(opacity))
      level = list(level[:min_length])
      opacity = list(opacity[:min_length])
      level_width = list(level_width[:min_length])
      # append with zeros
      while len(level) < 3:
          level.append(0)
      while len(opacity) < 3:
          opacity.append(0)
      while len(level_width) < 3:
          level_width.append(0)
      for i in range(1, 4):
          tf_kwargs["level" + str(i)] = level[i - 1]
          tf_kwargs["opacity" + str(i)] = opacity[i - 1]
          tf_kwargs["width" + str(i)] = level_width[i - 1]
      tf = ipv.TransferFunctionWidgetJs3(**tf_kwargs)
      gcf()  # make sure a current container/figure exists
      if controls:
          current.container.children = (tf.control(max_opacity=max_opacity),) + current.container.children
      return tf
docs: Create a transfer function, see volshow.