code: def unbounded_piecewise_quadratic_transform(
      x, w_tilde, v_tilde, upper=1, lower=0, inverse=False
  ):
      assert upper > lower
      _range = upper - lower
      inside_interval_mask = (x >= lower) & (x < upper)
      outside_interval_mask = ~inside_interval_mask
  
      outputs = torch.zeros_like(x)
      log_j = torch.zeros_like(x)
  
      outputs[outside_interval_mask] = x[outside_interval_mask]
      log_j[outside_interval_mask] = 0
  
      output, _log_j = piecewise_quadratic_transform(
          (x[inside_interval_mask] - lower) / _range,
          w_tilde[inside_interval_mask, :],
          v_tilde[inside_interval_mask, :],
          inverse=inverse,
      )
      outputs[inside_interval_mask] = output * _range + lower
      if not inverse:
          # the before and after transformation cancel out, so the log_j would be just as it is.
          log_j[inside_interval_mask] = _log_j
      else:
          log_j = None
      return outputs, log_j
  
file_path: NeMo/nemo/collections/tts/parts/utils/splines.py
imports: import numpy
  import torch
  import torch.nn.functional
label_desc: Use image node_id 3 for calling a global function with example usage: unbounded_piecewise_quadratic_transform(x, w_tilde, v_tilde, upper, lower, inverse) and returns: outputs,  log_j