code: def _prepare_pooling_downsampling(
      pooling_kernel_sizes,
      n_freq_downsample,
      in_len,
      out_len,
      num_blocks,
      num_stacks,
  ):
      def _check_sizes(tup, name):
          raise_if_not(
              len(tup) == num_stacks,
              f"the length of {name} must match the number of stacks.",
          )
          raise_if_not(
              all([len(i) == num_blocks for i in tup]),
              f"the length of each tuple in {name} must be `num_blocks={num_blocks}`",
          )
  
      if pooling_kernel_sizes is None:
          # make stacks handle different frequencies
          # go from in_len/2 to 1 in num_stacks steps:
          max_v = max(in_len // 2, 1)
          pooling_kernel_sizes = tuple(
              (int(v),) * num_blocks
              for v in max_v // np.geomspace(1, max_v, num_stacks)
          )
          logger.info(
              f"(N-HiTS): Using automatic kernel pooling size: {pooling_kernel_sizes}."
          )
      else:
          # check provided pooling format
          _check_sizes(pooling_kernel_sizes, "`pooling_kernel_sizes`")
  
      if n_freq_downsample is None:
          # go from out_len/2 to 1 in num_stacks steps:
          max_v = max(out_len // 2, 1)
          n_freq_downsample = tuple(
              (int(v),) * num_blocks
              for v in max_v // np.geomspace(1, max_v, num_stacks)
          )
          logger.info(
              f"(N-HiTS):  Using automatic downsampling coefficients: {n_freq_downsample}."
          )
      else:
          # check provided downsample format
          _check_sizes(n_freq_downsample, "`n_freq_downsample`")
  
          # check that last value is 1
          raise_if_not(
              n_freq_downsample[-1][-1] == 1,
              "the downsampling coefficient of the last block of the last stack must be 1 "
              + "(i.e., `n_freq_downsample[-1][-1]`).",
          )
  
      return pooling_kernel_sizes, n_freq_downsample
  
imports: from typing import List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from darts.logging import get_logger, raise_if_not
  from darts.models.forecasting.pl_forecasting_module import PLPastCovariatesModule, io_processor
  from darts.models.forecasting.torch_forecasting_model import PastCovariatesTorchModel
  from darts.utils.torch import MonteCarloDropout
label_desc: Use image node_id 3 for calling the NHiTSModel obj's underlying member method code with example usage: obj._prepare_pooling_downsampling(pooling_kernel_sizes, n_freq_downsample, in_len, out_len, num_blocks, num_stacks) and returns: pooling_kernel_sizes,  n_freq_downsample