class_docstr: A class representing probability distributions.
class_docstr_tok: ["A","class","representing","probability","distributions","."]
docstr: Returns a Tensor of shape (len(level), *batch_size) with the
  corresponding quantiles.
docstr_tok: ["Returns","a","Tensor","of","shape","(","len","(","level",")",",","*","batch_size",")","with","the","corresponding","quantiles","."]
code: def _tensor_cdf_bisection(
      self, level: Tensor, tol=1e-6, max_iter=120
  ) -> Tensor:
      r"""
      Returns a Tensor of shape (len(level), *batch_size) with the
      corresponding quantiles.
      """
      F = self.F
      local_max_support_val = min(1e16, MAX_SUPPORT_VAL)
  
      try:
          support_lb, support_ub = self.support_min_max
          support_lb = F.broadcast_maximum(
              F.broadcast_minimum(
                  support_lb,
                  F.ones(self.batch_shape) * local_max_support_val,
              ),
              F.ones(self.batch_shape) * -local_max_support_val,
          )
          support_ub = F.broadcast_maximum(
              F.broadcast_minimum(
                  support_ub,
                  F.ones(self.batch_shape) * local_max_support_val,
              ),
              F.ones(self.batch_shape) * -local_max_support_val,
          )
  
          upper_bound = F.broadcast_like(
              support_lb.expand_dims(axis=0),
              level,
              lhs_axes=0,
              rhs_axes=0,
          )
          lower_bound = F.broadcast_like(
              support_ub.expand_dims(axis=0),
              level,
              lhs_axes=0,
              rhs_axes=0,
          )
      except NotImplementedError:
          # default to R if not defined
          upper_bound = (
              F.ones((len(level), *self.batch_shape))
              * local_max_support_val
          )
          lower_bound = (
              F.ones((len(level), *self.batch_shape))
              * -local_max_support_val
          )
  
      for _ in range(self.all_dim):
          level = level.expand_dims(axis=-1)
  
      q = 0.5 * F.broadcast_add(upper_bound, lower_bound)
      val = self.cdf(q) - level
  
      cnt = 0
      while F.sum(F.abs(val) > tol) > 0 and cnt < max_iter:
          mask_g = F.greater(val, tol)
          mask_l = F.lesser(val, -tol)
          mask_done = F.lesser_equal(F.abs(val), tol)
  
          upper_bound = (
              F.broadcast_mul(q, mask_g)
              + F.broadcast_mul(upper_bound, mask_l)
              + F.broadcast_mul(q, mask_done)
          )
          lower_bound = (
              F.broadcast_mul(q, mask_l)
              + F.broadcast_mul(lower_bound, mask_g)
              + F.broadcast_mul(q, mask_done)
          )
  
          q = 0.5 * F.broadcast_add(upper_bound, lower_bound)
          val = self.cdf(q) - level
          cnt += 1
      return q
  
imports: from typing import cast, Any, List, Optional, Tuple
  import mxnet
  import numpy
  from mxnet import autograd
  from gluonts.mx import Tensor
label_desc: Use image node_id 19 for calling the Distribution obj's underlying member method code with example usage: obj._tensor_cdf_bisection(level, tol, max_iter) and returns: q