code: def effective_sample_size(input, chain_dim=0, sample_dim=1):
      """
      Computes effective sample size of input.
  
      Reference:
  
      [1] `Introduction to Markov Chain Monte Carlo`,
          Charles J. Geyer
  
      [2] `Stan Reference Manual version 2.18`,
          Stan Development Team
  
      :param torch.Tensor input: the input tensor.
      :param int chain_dim: the chain dimension.
      :param int sample_dim: the sample dimension.
      :returns torch.Tensor: effective sample size of ``input``.
      """
      assert input.dim() >= 2
      assert input.size(sample_dim) >= 2
      # change input.shape to 1 x 1 x input.shape
      # then transpose sample_dim with 0, chain_dim with 1
      sample_dim = (
          input.dim() + sample_dim if sample_dim < 0 else sample_dim
      )
      chain_dim = (
          input.dim() + chain_dim if chain_dim < 0 else chain_dim
      )
      assert chain_dim != sample_dim
      input = input.reshape((1, 1) + input.shape)
      input = input.transpose(0, sample_dim + 2).transpose(
          1, chain_dim + 2
      )
  
      N, C = input.size(0), input.size(1)
      # find autocovariance for each chain at lag k
      gamma_k_c = autocovariance(input, dim=0)  # N x C x sample_shape
  
      # find autocorrelation at lag k (from Stan reference)
      var_within, var_estimator = _compute_chain_variance_stats(input)
      rho_k = (
          var_estimator - var_within + gamma_k_c.mean(dim=1)
      ) / var_estimator
      rho_k[0] = 1  # correlation at lag 0 is always 1
  
      # initial positive sequence (formula 1.18 in [1]) applied for autocorrelation
      Rho_k = rho_k if N % 2 == 0 else rho_k[:-1]
      Rho_k = Rho_k.reshape((N // 2, 2) + Rho_k.shape[1:]).sum(dim=1)
  
      # separate the first index
      Rho_init = Rho_k[0]
  
      if Rho_k.size(0) > 1:
          # Theoretically, Rho_k is positive, but due to noise of correlation computation,
          # Rho_k might not be positive at some point. So we need to truncate (ignore first index).
          Rho_positive = Rho_k[1:].clamp(min=0)
  
          # Now we make the initial monotone (decreasing) sequence.
          Rho_monotone = _cummin(Rho_positive)
  
          # Formula 1.19 in [1]
          tau = -1 + 2 * Rho_init + 2 * Rho_monotone.sum(dim=0)
      else:
          tau = -1 + 2 * Rho_init
  
      n_eff = C * N / tau
      return n_eff.squeeze(max(sample_dim, chain_dim)).squeeze(
          min(sample_dim, chain_dim)
      )
  
imports: import math
  import numbers
  import torch
  from torch.fft import irfft, rfft
  from .tensor_utils import next_fast_len
label_desc: Use image node_id 7 for calling a global function with example usage: effective_sample_size(input, chain_dim, sample_dim) and returns: n_eff