class_docstr: Affine MaskedAutoregressiveFlow bijector.
  
  The affine autoregressive flow [(Papamakarios et al., 2016)][3] provides a
  relatively simple framework for user-specified (deep) architectures to learn a
  distribution over continuous events.  Regarding terminology,
  
    'Autoregressive models decompose the joint density as a product of
    conditionals, and model each conditional in turn.  Normalizing flows
    transform a base density (e.g. a standard Gaussian) into the target density
    by an invertible transformation with tractable Jacobian.'
    [(Papamakarios et al., 2016)][3]
  
  In other words, the 'autoregressive property' is equivalent to the
  decomposition, `p(x) = prod{ p(x[perm[i]] | x[perm[0:i]]) : i=0, ..., d }`
  where `perm` is some permutation of `{0, ..., d}`.  In the simple case where
  the permutation is identity this reduces to:
  `p(x) = prod{ p(x[i] | x[0:i]) : i=0, ..., d }`.
  
  In TensorFlow Probability, 'normalizing flows' are implemented as
  `tfp.bijectors.Bijector`s.  The `forward` 'autoregression' is implemented
  using a `tf.while_loop` and a deep neural network (DNN) with masked weights
  such that the autoregressive property is automatically met in the `inverse`.
  
  A `TransformedDistribution` using `MaskedAutoregressiveFlow(...)` uses the
  (expensive) forward-mode calculation to draw samples and the (cheap)
  reverse-mode calculation to compute log-probabilities.  Conversely, a
  `TransformedDistribution` using `Invert(MaskedAutoregressiveFlow(...))` uses
  the (expensive) forward-mode calculation to compute log-probabilities and the
  (cheap) reverse-mode calculation to compute samples.  See 'Example Use'
  [below] for more details.
  
  Given a `shift_and_log_scale_fn`, the forward and inverse transformations are
  (a sequence of) affine transformations.  A 'valid' `shift_and_log_scale_fn`
  must compute each `shift` (aka `loc` or 'mu' in [Germain et al. (2015)][1])
  and `log(scale)` (aka 'alpha' in [Germain et al. (2015)][1]) such that each
  are broadcastable with the arguments to `forward` and `inverse`, i.e., such
  that the calculations in `forward`, `inverse` [below] are possible.
  
  For convenience, `tfp.bijectors.AutoregressiveNetwork` is offered as a
  possible `shift_and_log_scale_fn` function.  It implements the MADE
  architecture [(Germain et al., 2015)][1].  MADE is a feed-forward network that
  computes a `shift` and `log(scale)` using masked dense layers in a deep
  neural network. Weights are masked to ensure the autoregressive property. It
  is possible that this architecture is suboptimal for your task. To build
  alternative networks, either change the arguments to
  `tfp.bijectors.AutoregressiveNetwork` or use some other architecture, e.g.,
  using `tf_keras.layers`.
  
  Warning: no attempt is made to validate that the `shift_and_log_scale_fn`
  enforces the 'autoregressive property'.
  
  Assuming `shift_and_log_scale_fn` has valid shape and autoregressive
  semantics, the forward transformation is
  
  ```python
  def forward(x):
    y = zeros_like(x)
    event_size = x.shape[-event_dims:].num_elements()
    for _ in range(event_size):
      shift, log_scale = shift_and_log_scale_fn(y)
      y = x * tf.exp(log_scale) + shift
    return y
  ```
  
  and the inverse transformation is
  
  ```python
  def inverse(y):
    shift, log_scale = shift_and_log_scale_fn(y)
    return (y - shift) / tf.exp(log_scale)
  ```
  
  Notice that the `inverse` does not need a for-loop.  This is because in the
  forward pass each calculation of `shift` and `log_scale` is based on the `y`
  calculated so far (not `x`).  In the `inverse`, the `y` is fully known, thus
  is equivalent to the scaling used in `forward` after `event_size` passes,
  i.e., the 'last' `y` used to compute `shift`, `log_scale`.  (Roughly speaking,
  this also proves the transform is bijective.)
  
  The `bijector_fn` argument allows specifying a more general coupling relation,
  such as the LSTM-inspired activation from [4], or Neural Spline Flow [5].  It
  must logically operate on each element of the input individually, and still
  obey the 'autoregressive property' described above.  The forward
  transformation is
  
  ```python
  def forward(x):
    y = zeros_like(x)
    event_size = x.shape[-event_dims:].num_elements()
    for _ in range(event_size):
      bijector = bijector_fn(y)
      y = bijector.forward(x)
    return y
  ```
  
  and inverse transformation is
  
  ```python
  def inverse(y):
      bijector = bijector_fn(y)
      return bijector.inverse(y)
  ```
  
  #### Examples
  
  ```python
  tfd = tfp.distributions
  tfb = tfp.bijectors
  
  dims = 2
  
  # A common choice for a normalizing flow is to use a Gaussian for the base
  # distribution.  (However, any continuous distribution would work.) Here, we
  # use `tfd.Sample` to create a joint Gaussian distribution with diagonal
  # covariance for the base distribution (note that in the Gaussian case,
  # `tfd.MultivariateNormalDiag` could also be used.)
  maf = tfd.TransformedDistribution(
      distribution=tfd.Sample(
          tfd.Normal(loc=0., scale=1.), sample_shape=[dims]),
      bijector=tfb.MaskedAutoregressiveFlow(
          shift_and_log_scale_fn=tfb.AutoregressiveNetwork(
              params=2, hidden_units=[512, 512])))
  
  x = maf.sample()  # Expensive; uses `tf.while_loop`, no Bijector caching.
  maf.log_prob(x)   # Almost free; uses Bijector caching.
  # Cheap; no `tf.while_loop` despite no Bijector caching.
  maf.log_prob(tf.zeros(dims))
  
  # [Papamakarios et al. (2016)][3] also describe an Inverse Autoregressive
  # Flow [(Kingma et al., 2016)][2]:
  iaf = tfd.TransformedDistribution(
      distribution=tfd.Sample(
          tfd.Normal(loc=0., scale=1.), sample_shape=[dims]),
      bijector=tfb.Invert(tfb.MaskedAutoregressiveFlow(
          shift_and_log_scale_fn=tfb.AutoregressiveNetwork(
              params=2, hidden_units=[512, 512]))))
  
  x = iaf.sample()  # Cheap; no `tf.while_loop` despite no Bijector caching.
  iaf.log_prob(x)   # Almost free; uses Bijector caching.
  # Expensive; uses `tf.while_loop`, no Bijector caching.
  iaf.log_prob(tf.zeros(dims))
  
  # In many (if not most) cases the default `shift_and_log_scale_fn` will be a
  # poor choice.  Here's an example of using a 'shift only' version and with a
  # different number/depth of hidden layers.
  made = tfb.AutoregressiveNetwork(params=1, hidden_units=[32])
  maf_no_scale_hidden2 = tfd.TransformedDistribution(
      distribution=tfd.Sample(
          tfd.Normal(loc=0., scale=1.), sample_shape=[dims]),
      bijector=tfb.MaskedAutoregressiveFlow(
          lambda y: (made(y)[..., 0], None),
          is_constant_jacobian=True))
  maf_no_scale_hidden2._made = made  # Ensure maf_no_scale_hidden2.trainable
  # NOTE: The last line ensures that maf_no_scale_hidden2.trainable_variables
  # will include all variables from `made`.
  ```
  
  #### Variable Tracking
  
  NOTE: Like all subclasses of `tfb.Bijector`, `tfb.MaskedAutoregressiveFlow`
  subclasses `tf.Module` for variable tracking.
  
  A `tfb.MaskedAutoregressiveFlow` instance saves a reference to the values
  passed as `shift_and_log_scale_fn` and `bijector_fn` to its constructor.
  Thus, for most values passed as `shift_and_log_scale_fn` or `bijector_fn`,
  variables referenced by those values will be found and tracked by the
  `tfb.MaskedAutoregressiveFlow` instance.  Please see the `tf.Module`
  documentation for further details.
  
  However, if the value passed to `shift_and_log_scale_fn` or `bijector_fn` is a
  Python function, then `tfb.MaskedAutoregressiveFlow` cannot automatically
  track variables used inside `shift_and_log_scale_fn` or `bijector_fn`.  To get
  `tfb.MaskedAutoregressiveFlow` to track such variables, either:
  
   1. Replace the Python function with a `tf.Module`, `tf_keras.Layer`,
      or other callable object through which `tf.Module` can find variables.
  
   2. Or, add a reference to the variables to the `tfb.MaskedAutoregressiveFlow`
      instance by setting an attribute -- for example:
      ````
      made1 = tfb.AutoregressiveNetwork(params=1, hidden_units=[10, 10])
      made2 = tfb.AutoregressiveNetwork(params=1, hidden_units=[10, 10])
      maf = tfb.MaskedAutoregressiveFlow(lambda y: (made1(y), made2(y) + 1.))
      maf._made_variables = made1.variables + made2.variables
      ````
  
  #### References
  
  [1]: Mathieu Germain, Karol Gregor, Iain Murray, and Hugo Larochelle. MADE:
       Masked Autoencoder for Distribution Estimation. In _International
       Conference on Machine Learning_, 2015. https://arxiv.org/abs/1502.03509
  
  [2]: Diederik P. Kingma, Tim Salimans, Rafal Jozefowicz, Xi Chen, Ilya
       Sutskever, and Max Welling. Improving Variational Inference with Inverse
       Autoregressive Flow. In _Neural Information Processing Systems_, 2016.
       https://arxiv.org/abs/1606.04934
  
  [3]: George Papamakarios, Theo Pavlakou, and Iain Murray. Masked
       Autoregressive Flow for Density Estimation. In _Neural Information
       Processing Systems_, 2017. https://arxiv.org/abs/1705.07057
  
  [4]: Diederik P Kingma, Tim Salimans, Max Welling. Improving Variational
       Inference with Inverse Autoregressive Flow. In _Neural Information
       Processing Systems_, 2016. https://arxiv.org/abs/1606.04934
  
  [5]: Conor Durkan, Artur Bekasov, Iain Murray, George Papamakarios. Neural
       Spline Flows, 2019. http://arxiv.org/abs/1906.04032
class_docstr_tok: ["Affine","MaskedAutoregressiveFlow","bijector",".","The","affine","autoregressive","flow","[","(","Papamakarios","et","al.",",","2016",")","]","[","3","]","provides","a","relatively","simple","framework","for","user-specified","(","deep",")","architectures","to","learn","a","distribution","over","continuous","events",".","Regarding","terminology",",","'Autoregressive","models","decompose","the","joint","density","as","a","product","of","conditionals",",","and","model","each","conditional","in","turn",".","Normalizing","flows","transform","a","base","density","(","e.g",".","a","standard","Gaussian",")","into","the","target","density","by","an","invertible","transformation","with","tractable","Jacobian",".","'","[","(","Papamakarios","et","al.",",","2016",")","]","[","3","]","In","other","words",",","the","'autoregressive","property","'","is","equivalent","to","the","decomposition",",","`","p","(","x",")","=","prod","{","p","(","x","[","perm","[","i","]","]","|","x","[","perm","[","0",":","i","]","]",")",":","i=0",",","...",",","d","}","`","where","`","perm","`","is","some","permutation","of","`","{","0",",","...",",","d","}","`",".","In","the","simple","case","where","the","permutation","is","identity","this","reduces","to",":","`","p","(","x",")","=","prod","{","p","(","x","[","i","]","|","x","[","0",":","i","]",")",":","i=0",",","...",",","d","}","`",".","In","TensorFlow","Probability",",","'normalizing","flows","'","are","implemented","as","`","tfp.bijectors.Bijector","`","s",".","The","`","forward","`","'autoregression","'","is","implemented","using","a","`","tf.while_loop","`","and","a","deep","neural","network","(","DNN",")","with","masked","weights","such","that","the","autoregressive","property","is","automatically","met","in","the","`","inverse","`",".","A","`","TransformedDistribution","`","using","`","MaskedAutoregressiveFlow","(","...",")","`","uses","the","(","expensive",")","forward-mode","calculation","to","draw","samples","and","the","(","cheap",")","reverse-mode","calculation","to","compute","log-probabilities",".","Conversely",",","a","`","TransformedDistribution","`","using","`","Invert","(","MaskedAutoregressiveFlow","(","...",")",")","`","uses","the","(","expensive",")","forward-mode","calculation","to","compute","log-probabilities","and","the","(","cheap",")","reverse-mode","calculation","to","compute","samples",".","See","'Example","Use'","[","below","]","for","more","details",".","Given","a","`","shift_and_log_scale_fn","`",",","the","forward","and","inverse","transformations","are","(","a","sequence","of",")","affine","transformations",".","A","'valid","'","`","shift_and_log_scale_fn","`","must","compute","each","`","shift","`","(","aka","`","loc","`","or","'mu","'","in","[","Germain","et","al",".","(","2015",")","]","[","1","]",")","and","`","log","(","scale",")","`","(","aka","'alpha","'","in","[","Germain","et","al",".","(","2015",")","]","[","1","]",")","such","that","each","are","broadcastable","with","the","arguments","to","`","forward","`","and","`","inverse","`",",","i.e.",",","such","that","the","calculations","in","`","forward","`",",","`","inverse","`","[","below","]","are","possible",".","For","convenience",",","`","tfp.bijectors.AutoregressiveNetwork","`","is","offered","as","a","possible","`","shift_and_log_scale_fn","`","function",".","It","implements","the","MADE","architecture","[","(","Germain","et","al.",",","2015",")","]","[","1","]",".","MADE","is","a","feed-forward","network","that","computes","a","`","shift","`","and","`","log","(","scale",")","`","using","masked","dense","layers","in","a","deep","neural","network",".","Weights","are","masked","to","ensure","the","autoregressive","property",".","It","is","possible","that","this","architecture","is","suboptimal","for","your","task",".","To","build","alternative","networks",",","either","change","the","arguments","to","`","tfp.bijectors.AutoregressiveNetwork","`","or","use","some","other","architecture",",","e.g.",",","using","`","tf_keras.layers","`",".","Warning",":","no","attempt","is","made","to","validate","that","the","`","shift_and_log_scale_fn","`","enforces","the","'autoregressive","property","'",".","Assuming","`","shift_and_log_scale_fn","`","has","valid","shape","and","autoregressive","semantics",",","the","forward","transformation","is","``","`","python","def","forward","(","x",")",":","y","=","zeros_like","(","x",")","event_size","=","x.shape","[","-event_dims",":","]",".num_elements","(",")","for","_","in","range","(","event_size",")",":","shift",",","log_scale","=","shift_and_log_scale_fn","(","y",")","y","=","x","*","tf.exp","(","log_scale",")","+","shift","return","y","``","`","and","the","inverse","transformation","is","``","`","python","def","inverse","(","y",")",":","shift",",","log_scale","=","shift_and_log_scale_fn","(","y",")","return","(","y","-","shift",")","\/","tf.exp","(","log_scale",")","``","`","Notice","that","the","`","inverse","`","does","not","need","a","for-loop",".","This","is","because","in","the","forward","pass","each","calculation","of","`","shift","`","and","`","log_scale","`","is","based","on","the","`","y","`","calculated","so","far","(","not","`","x","`",")",".","In","the","`","inverse","`",",","the","`","y","`","is","fully","known",",","thus","is","equivalent","to","the","scaling","used","in","`","forward","`","after","`","event_size","`","passes",",","i.e.",",","the","'last","'","`","y","`","used","to","compute","`","shift","`",",","`","log_scale","`",".","(","Roughly","speaking",",","this","also","proves","the","transform","is","bijective",".",")","The","`","bijector_fn","`","argument","allows","specifying","a","more","general","coupling","relation",",","such","as","the","LSTM-inspired","activation","from","[","4","]",",","or","Neural","Spline","Flow","[","5","]",".","It","must","logically","operate","on","each","element","of","the","input","individually",",","and","still","obey","the","'autoregressive","property","'","described","above",".","The","forward","transformation","is","``","`","python","def","forward","(","x",")",":","y","=","zeros_like","(","x",")","event_size","=","x.shape","[","-event_dims",":","]",".num_elements","(",")","for","_","in","range","(","event_size",")",":","bijector","=","bijector_fn","(","y",")","y","=","bijector.forward","(","x",")","return","y","``","`","and","inverse","transformation","is","``","`","python","def","inverse","(","y",")",":","bijector","=","bijector_fn","(","y",")","return","bijector.inverse","(","y",")","``","`","#","#","#","#","Examples","``","`","python","tfd","=","tfp.distributions","tfb","=","tfp.bijectors","dims","=","2","#","A","common","choice","for","a","normalizing","flow","is","to","use","a","Gaussian","for","the","base","#","distribution",".","(","However",",","any","continuous","distribution","would","work",".",")","Here",",","we","#","use","`","tfd.Sample","`","to","create","a","joint","Gaussian","distribution","with","diagonal","#","covariance","for","the","base","distribution","(","note","that","in","the","Gaussian","case",",","#","`","tfd.MultivariateNormalDiag","`","could","also","be","used",".",")","maf","=","tfd.TransformedDistribution","(","distribution=tfd.Sample","(","tfd.Normal","(","loc=0.",",","scale=1",".",")",",","sample_shape=","[","dims","]",")",",","bijector=tfb.MaskedAutoregressiveFlow","(","shift_and_log_scale_fn=tfb.AutoregressiveNetwork","(","params=2",",","hidden_units=","[","512",",","512","]",")",")",")","x","=","maf.sample","(",")","#","Expensive",";","uses","`","tf.while_loop","`",",","no","Bijector","caching",".","maf.log_prob","(","x",")","#","Almost","free",";","uses","Bijector","caching",".","#","Cheap",";","no","`","tf.while_loop","`","despite","no","Bijector","caching",".","maf.log_prob","(","tf.zeros","(","dims",")",")","#","[","Papamakarios","et","al",".","(","2016",")","]","[","3","]","also","describe","an","Inverse","Autoregressive","#","Flow","[","(","Kingma","et","al.",",","2016",")","]","[","2","]",":","iaf","=","tfd.TransformedDistribution","(","distribution=tfd.Sample","(","tfd.Normal","(","loc=0.",",","scale=1",".",")",",","sample_shape=","[","dims","]",")",",","bijector=tfb.Invert","(","tfb.MaskedAutoregressiveFlow","(","shift_and_log_scale_fn=tfb.AutoregressiveNetwork","(","params=2",",","hidden_units=","[","512",",","512","]",")",")",")",")","x","=","iaf.sample","(",")","#","Cheap",";","no","`","tf.while_loop","`","despite","no","Bijector","caching",".","iaf.log_prob","(","x",")","#","Almost","free",";","uses","Bijector","caching",".","#","Expensive",";","uses","`","tf.while_loop","`",",","no","Bijector","caching",".","iaf.log_prob","(","tf.zeros","(","dims",")",")","#","In","many","(","if","not","most",")","cases","the","default","`","shift_and_log_scale_fn","`","will","be","a","#","poor","choice",".","Here","'s","an","example","of","using","a","'shift","only","'","version","and","with","a","#","different","number\/depth","of","hidden","layers",".","made","=","tfb.AutoregressiveNetwork","(","params=1",",","hidden_units=","[","32","]",")","maf_no_scale_hidden2","=","tfd.TransformedDistribution","(","distribution=tfd.Sample","(","tfd.Normal","(","loc=0.",",","scale=1",".",")",",","sample_shape=","[","dims","]",")",",","bijector=tfb.MaskedAutoregressiveFlow","(","lambda","y",":","(","made","(","y",")","[","...",",","0","]",",","None",")",",","is_constant_jacobian=True",")",")","maf_no_scale_hidden2._made","=","made","#","Ensure","maf_no_scale_hidden2.trainable","#","NOTE",":","The","last","line","ensures","that","maf_no_scale_hidden2.trainable_variables","#","will","include","all","variables","from","`","made","`",".","``","`","#","#","#","#","Variable","Tracking","NOTE",":","Like","all","subclasses","of","`","tfb.Bijector","`",",","`","tfb.MaskedAutoregressiveFlow","`","subclasses","`","tf.Module","`","for","variable","tracking",".","A","`","tfb.MaskedAutoregressiveFlow","`","instance","saves","a","reference","to","the","values","passed","as","`","shift_and_log_scale_fn","`","and","`","bijector_fn","`","to","its","constructor",".","Thus",",","for","most","values","passed","as","`","shift_and_log_scale_fn","`","or","`","bijector_fn","`",",","variables","referenced","by","those","values","will","be","found","and","tracked","by","the","`","tfb.MaskedAutoregressiveFlow","`","instance",".","Please","see","the","`","tf.Module","`","documentation","for","further","details",".","However",",","if","the","value","passed","to","`","shift_and_log_scale_fn","`","or","`","bijector_fn","`","is","a","Python","function",",","then","`","tfb.MaskedAutoregressiveFlow","`","can","not","automatically","track","variables","used","inside","`","shift_and_log_scale_fn","`","or","`","bijector_fn","`",".","To","get","`","tfb.MaskedAutoregressiveFlow","`","to","track","such","variables",",","either",":","1",".","Replace","the","Python","function","with","a","`","tf.Module","`",",","`","tf_keras.Layer","`",",","or","other","callable","object","through","which","`","tf.Module","`","can","find","variables",".","2",".","Or",",","add","a","reference","to","the","variables","to","the","`","tfb.MaskedAutoregressiveFlow","`","instance","by","setting","an","attribute","--","for","example",":","``","``","made1","=","tfb.AutoregressiveNetwork","(","params=1",",","hidden_units=","[","10",",","10","]",")","made2","=","tfb.AutoregressiveNetwork","(","params=1",",","hidden_units=","[","10",",","10","]",")","maf","=","tfb.MaskedAutoregressiveFlow","(","lambda","y",":","(","made1","(","y",")",",","made2","(","y",")","+","1",".",")",")","maf._made_variables","=","made1.variables","+","made2.variables","``","``","#","#","#","#","References","[","1","]",":","Mathieu","Germain",",","Karol","Gregor",",","Iain","Murray",",","and","Hugo","Larochelle",".","MADE",":","Masked","Autoencoder","for","Distribution","Estimation",".","In","_International","Conference","on","Machine","Learning_",",","2015.","https",":","\/\/arxiv.org\/abs\/1502.03509","[","2","]",":","Diederik","P.","Kingma",",","Tim","Salimans",",","Rafal","Jozefowicz",",","Xi","Chen",",","Ilya","Sutskever",",","and","Max","Welling",".","Improving","Variational","Inference","with","Inverse","Autoregressive","Flow",".","In","_Neural","Information","Processing","Systems_",",","2016.","https",":","\/\/arxiv.org\/abs\/1606.04934","[","3","]",":","George","Papamakarios",",","Theo","Pavlakou",",","and","Iain","Murray",".","Masked","Autoregressive","Flow","for","Density","Estimation",".","In","_Neural","Information","Processing","Systems_",",","2017.","https",":","\/\/arxiv.org\/abs\/1705.07057","[","4","]",":","Diederik","P","Kingma",",","Tim","Salimans",",","Max","Welling",".","Improving","Variational","Inference","with","Inverse","Autoregressive","Flow",".","In","_Neural","Information","Processing","Systems_",",","2016.","https",":","\/\/arxiv.org\/abs\/1606.04934","[","5","]",":","Conor","Durkan",",","Artur","Bekasov",",","Iain","Murray",",","George","Papamakarios",".","Neural","Spline","Flows",",","2019.","http",":","\/\/arxiv.org\/abs\/1906.04032"]
code: def _forward(self, x, **kwargs):
      static_event_size = tensorshape_util.num_elements(
          tensorshape_util.with_rank_at_least(
              x.shape, self._event_ndims
          )[-self._event_ndims :]
      )
  
      if self._unroll_loop:
          if not static_event_size:
              raise ValueError(
                  "The final {} dimensions of `x` must be known at graph "
                  "construction time if `unroll_loop=True`. `x.shape: {!r}`".format(
                      self._event_ndims, x.shape
                  )
              )
          y = tf.zeros_like(x, name="y0")
  
          for _ in range(static_event_size):
              y = self._bijector_fn(y, **kwargs).forward(x)
          return y
  
      event_size = ps.reduce_prod(ps.shape(x)[-self._event_ndims :])
      y0 = tf.zeros_like(x, name="y0")
      # call the template once to ensure creation
      if not tf.executing_eagerly():
          _ = self._bijector_fn(y0, **kwargs).forward(y0)
  
      def _loop_body(y0):
          """While-loop body for autoregression calculation."""
          # Set caching device to avoid re-getting the tf.Variable for every while
          # loop iteration.
          with tf1.variable_scope(tf1.get_variable_scope()) as vs:
              if (
                  vs.caching_device is None
                  and not tf.executing_eagerly()
              ):
                  vs.set_caching_device(lambda op: op.device)
              bijector = self._bijector_fn(y0, **kwargs)
          y = bijector.forward(x)
          return (y,)
  
      (y,) = tf.while_loop(
          cond=lambda _: True,
          body=_loop_body,
          loop_vars=(y0,),
          maximum_iterations=event_size,
      )
      return y
  
imports: import numpy
  import six
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.bijectors import chain
  from tensorflow_probability.python.bijectors import scale
  from tensorflow_probability.python.bijectors import shift
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import tf_keras
  from tensorflow_probability.python.math.numeric import clip_by_value_preserve_gradient
  from tensorflow.python.util import deprecation
label_desc: Use image node_id 3 for calling the MaskedAutoregressiveFlow obj's underlying member method code with example usage: obj._forward(x) and returns: y, y, y