parameters: (bijector_list, compute_forward=True)
return_statement: return min_event_ndims
docstring: Computes the min_event_ndims associated with the give list of bijectors.
  
    Given a list `bijector_list` of bijectors, compute the min_event_ndims that is
    associated with the composition of bijectors in that list.
  
    min_event_ndims is the # of right most dimensions for which the bijector has
    done necessary computation on (i.e. the non-broadcastable part of the
    computation).
  
    We can derive the min_event_ndims for a chain of bijectors as follows:
  
    In the case where there are no rank changing bijectors, this will simply be
    `max(b.forward_min_event_ndims for b in bijector_list)`. This is because the
    bijector with the most forward_min_event_ndims requires the most dimensions,
    and hence the chain also requires operating on those dimensions.
  
    However in the case of rank changing, more care is needed in determining the
    exact amount of dimensions. Padding dimensions causes subsequent bijectors to
    operate on the padded dimensions, and Removing dimensions causes bijectors to
    operate more left.
  
    Args:
      bijector_list: List of bijectors to be composed by chain.
      compute_forward: Boolean. If True, computes the min_event_ndims associated
        with a forward call to Chain, and otherwise computes the min_event_ndims
        associated with an inverse call to Chain. The latter is the same as the
        min_event_ndims associated with a forward call to Invert(Chain(....)).
  
    Returns:
      min_event_ndims
docstring_summary: Computes the min_event_ndims associated with the give list of bijectors.
docstring_tokens: Computes the min_event_ndims associated with the give list of bijectors .
function: def _compute_min_event_ndims(bijector_list, compute_forward=True):
    """Computes the min_event_ndims associated with the give list of bijectors.
  
    Given a list `bijector_list` of bijectors, compute the min_event_ndims that is
    associated with the composition of bijectors in that list.
  
    min_event_ndims is the # of right most dimensions for which the bijector has
    done necessary computation on (i.e. the non-broadcastable part of the
    computation).
  
    We can derive the min_event_ndims for a chain of bijectors as follows:
  
    In the case where there are no rank changing bijectors, this will simply be
    `max(b.forward_min_event_ndims for b in bijector_list)`. This is because the
    bijector with the most forward_min_event_ndims requires the most dimensions,
    and hence the chain also requires operating on those dimensions.
  
    However in the case of rank changing, more care is needed in determining the
    exact amount of dimensions. Padding dimensions causes subsequent bijectors to
    operate on the padded dimensions, and Removing dimensions causes bijectors to
    operate more left.
  
    Args:
      bijector_list: List of bijectors to be composed by chain.
      compute_forward: Boolean. If True, computes the min_event_ndims associated
        with a forward call to Chain, and otherwise computes the min_event_ndims
        associated with an inverse call to Chain. The latter is the same as the
        min_event_ndims associated with a forward call to Invert(Chain(....)).
  
    Returns:
      min_event_ndims
    """
    min_event_ndims = 0
    # This is a mouthful, but what this encapsulates is that if not for rank
    # changing bijectors, we'd only need to compute the largest of the min
    # required ndims. Hence "max_min". Due to rank changing bijectors, we need to
    # account for synthetic rank growth / synthetic rank decrease from a rank
    # changing bijector.
    rank_changed_adjusted_max_min_event_ndims = 0
  
    if compute_forward:
      bijector_list = reversed(bijector_list)
  
    for b in bijector_list:
      if compute_forward:
        current_min_event_ndims = b.forward_min_event_ndims
        current_inverse_min_event_ndims = b.inverse_min_event_ndims
      else:
        current_min_event_ndims = b.inverse_min_event_ndims
        current_inverse_min_event_ndims = b.forward_min_event_ndims
  
      # New dimensions were touched.
      if rank_changed_adjusted_max_min_event_ndims < current_min_event_ndims:
        min_event_ndims += (
            current_min_event_ndims - rank_changed_adjusted_max_min_event_ndims)
      rank_changed_adjusted_max_min_event_ndims = max(
          current_min_event_ndims, rank_changed_adjusted_max_min_event_ndims)
  
      # If the number of dimensions has increased via forward, then
      # inverse_min_event_ndims > forward_min_event_ndims, and hence the
      # dimensions we computed on, have moved left (so we have operated
      # on additional dimensions).
      # Conversely, if the number of dimensions has decreased via forward,
      # then we have inverse_min_event_ndims < forward_min_event_ndims,
      # and so we will have operated on fewer right most dimensions.
  
      number_of_changed_dimensions = (
          current_min_event_ndims - current_inverse_min_event_ndims)
      rank_changed_adjusted_max_min_event_ndims -= number_of_changed_dimensions
    return min_event_ndims
function_tokens: def _compute_min_event_ndims ( bijector_list , compute_forward = True ) : min_event_ndims = 0 # This is a mouthful, but what this encapsulates is that if not for rank # changing bijectors, we'd only need to compute the largest of the min # required ndims. Hence "max_min". Due to rank changing bijectors, we need to # account for synthetic rank growth / synthetic rank decrease from a rank # changing bijector. rank_changed_adjusted_max_min_event_ndims = 0 if compute_forward : bijector_list = reversed ( bijector_list ) for b in bijector_list : if compute_forward : current_min_event_ndims = b . forward_min_event_ndims current_inverse_min_event_ndims = b . inverse_min_event_ndims else : current_min_event_ndims = b . inverse_min_event_ndims current_inverse_min_event_ndims = b . forward_min_event_ndims # New dimensions were touched. if rank_changed_adjusted_max_min_event_ndims < current_min_event_ndims : min_event_ndims += ( current_min_event_ndims - rank_changed_adjusted_max_min_event_ndims ) rank_changed_adjusted_max_min_event_ndims = max ( current_min_event_ndims , rank_changed_adjusted_max_min_event_ndims ) # If the number of dimensions has increased via forward, then # inverse_min_event_ndims > forward_min_event_ndims, and hence the # dimensions we computed on, have moved left (so we have operated # on additional dimensions). # Conversely, if the number of dimensions has decreased via forward, # then we have inverse_min_event_ndims < forward_min_event_ndims, # and so we will have operated on fewer right most dimensions. number_of_changed_dimensions = ( current_min_event_ndims - current_inverse_min_event_ndims ) rank_changed_adjusted_max_min_event_ndims -= number_of_changed_dimensions return min_event_ndims