code: def get_distinct_colors(num_colors, opacity=0.95):
      """Gets ``num_colors`` most distinguishable colors.
      Uses color maps "tab10", "tab20" or "viridis" depending on the
      number of colors needed.
      See above color pallettes here:
      https://matplotlib.org/stable/tutorials/colors/colormaps.html
  
      Parameters
      ----------
      num_colors : `int`
          The number of colors needed.
      opacity : `float`, default 0.95
          The opacity of the color. This has to be a number between 0 and 1.
  
      Returns
      -------
      colors : `list` [`str`]
          A list of string colors in RGB.
      """
      if opacity < 0 or opacity > 1:
          raise ValueError("Opacity must be between 0 and 1.")
  
      if num_colors <= 10:
          colors = get_cmap("tab10").colors
      elif num_colors <= 20:
          colors = get_cmap("tab20").colors
      elif num_colors <= 256:
          # Removes default opacity by ":3".
          colors = get_cmap(name="viridis")(
              np.linspace(0, 1, num_colors)
          )[:, :3]
      else:
          raise ValueError("The maximum number of colors is 256.")
  
      result = []
      for color in colors:
          # Converts the color components to "rgba" format
          color = f"rgba{int(color[0] * 255), int(color[1] * 255), int(color[2] * 255), opacity}"
          result.append(color)
      return result[:num_colors]
  
imports: import numpy
  from matplotlib.cm import get_cmap
  from plotly.colors import DEFAULT_PLOTLY_COLORS
  from plotly.colors import n_colors
  from plotly.colors import validate_colors
label_desc: Use image node_id 2 for calling a global function with example usage: get_distinct_colors(num_colors, opacity) and returns: result