code: def safe_qbeta(p, shape1, shape2, lower_tail=True):
      assert len(p) == len(shape1) and len(p) == len(shape2)
      is_0 = shape1 <= 0
      is_1 = shape2 <= 0
      ok = ~(is_0 | is_1)
      x = np.zeros(len(p))
      x[ok] = qbeta(
          p[ok], shape1[ok], shape2[ok], lower_tail=lower_tail
      )
      x[
          is_0 & ~is_1
      ] = 0  # density concentrated at x = 0 (for alpha == 0)
      x[
          is_1 & ~is_0
      ] = 1  # density concentrated at x = 1 (for beta == 0)
      x[
          is_0 & is_1
      ] = np.nan  # shouldn't happen in our case (alpha == beta == 0)
      return x
  
file_path: scattertext/scattertext/termscoring/lrc.py
imports: from typing import Union
  import numpy
  import pandas
  from scipy.stats import beta
  from scattertext import CorpusBasedTermScorer
label_desc: Use image node_id 5 for calling a global function with example usage: safe_qbeta(p, shape1, shape2, lower_tail) and returns: x