code: def conditional_affine_coupling(
      input_dim,
      context_dim,
      hidden_dims=None,
      split_dim=None,
      dim=-1,
      **kwargs,
  ):
      """
      A helper function to create an
      :class:`~pyro.distributions.transforms.ConditionalAffineCoupling` object that
      takes care of constructing a dense network with the correct input/output
      dimensions.
  
      :param input_dim: Dimension of input variable
      :type input_dim: int
      :param context_dim: Dimension of context variable
      :type context_dim: int
      :param hidden_dims: The desired hidden dimensions of the dense network. Defaults
          to using [10*input_dim]
      :type hidden_dims: list[int]
      :param split_dim: The dimension to split the input on for the coupling
          transform. Defaults to using input_dim // 2
      :type split_dim: int
      :param dim: the tensor dimension on which to split. This value must be negative
          and defines the event dim as `abs(dim)`.
      :type dim: int
      :param log_scale_min_clip: The minimum value for clipping the log(scale) from
          the autoregressive NN
      :type log_scale_min_clip: float
      :param log_scale_max_clip: The maximum value for clipping the log(scale) from
          the autoregressive NN
      :type log_scale_max_clip: float
  
      """
      if not isinstance(input_dim, int):
          if len(input_dim) != -dim:
              raise ValueError(
                  "event shape {} must have same length as event_dim {}".format(
                      input_dim, -dim
                  )
              )
          event_shape = input_dim
          extra_dims = reduce(operator.mul, event_shape[(dim + 1) :], 1)
      else:
          event_shape = [input_dim]
          extra_dims = 1
      event_shape = list(event_shape)
  
      if split_dim is None:
          split_dim = event_shape[dim] // 2
      if hidden_dims is None:
          hidden_dims = [10 * event_shape[dim] * extra_dims]
  
      nn = ConditionalDenseNN(
          split_dim * extra_dims,
          context_dim,
          hidden_dims,
          [
              (event_shape[dim] - split_dim) * extra_dims,
              (event_shape[dim] - split_dim) * extra_dims,
          ],
      )
      return ConditionalAffineCoupling(split_dim, nn, dim=dim, **kwargs)
  
imports: import operator
  from functools import partial, reduce
  import torch
  from torch.distributions.utils import _sum_rightmost
  from pyro.nn import ConditionalDenseNN, DenseNN
  from ..None import constraints
  from ..conditional import ConditionalTransformModule
  from ..torch_transform import TransformModule
  from ..transforms.utils import clamp_preserve_gradients
  from ..util import copy_docs_from
label_desc: Use image node_id 2 for calling a global function with example usage: conditional_affine_coupling(input_dim, context_dim, hidden_dims, split_dim, dim) and returns: ConditionalAffineCoupling