code: def plot_regression_from_trace(
      fitted, observed, ax=None, chains=None, multidim_ind=None
  ):
      traces = [
          fitted.trace,
      ]
      xi, yi, sigx, sigy = observed
  
      if multidim_ind is not None:
          xi = xi[multidim_ind]
  
      x = np.linspace(np.min(xi) - 0.5, np.max(xi) + 0.5, 50)
  
      for i, trace in enumerate(traces):
          if (
              "theta" in trace.varnames
              and "slope" not in trace.varnames
          ):
              trace.add_values({"slope": np.tan(trace["theta"])})
  
          if multidim_ind is not None:
              trace_slope = trace["slope"][:, multidim_ind]
          else:
              trace_slope = trace["slope"][:, 0]
  
          if chains is not None:
              for chain in range(
                  100, len(trace) * trace.nchains, chains
              ):
                  y = trace["inter"][chain] + trace_slope[chain] * x
                  ax.plot(x, y, alpha=0.03, c="red")
  
          # plot the best-fit line only
          H2D, bins1, bins2 = np.histogram2d(
              trace_slope, trace["inter"], bins=50
          )
  
          w = np.where(H2D == H2D.max())
  
          # choose the maximum posterior slope and intercept
          slope_best = bins1[w[0][0]]
          intercept_best = bins2[w[1][0]]
  
          print("beta:", slope_best, "alpha:", intercept_best)
          y = intercept_best + slope_best * x
  
          # y_pre = fitted.predict(x[:, None])
          ax.plot(x, y, ":", label="fitted")
  
          ax.legend()
          break
  
imports: import numpy
  import matplotlib.pyplot
  from scipy import optimize
  from astroML.linear_model import TLS_logL, LinearRegression
label_desc: Use image node_id 3 for calling a global function with example usage: plot_regression_from_trace(fitted, observed, ax, chains, multidim_ind) without return types