class_docstr: A downsampling layer with an optional convolution.
  
  :param channels: channels in the inputs and outputs.
  :param use_conv: a bool determining if a convolution is applied.
class_docstr_tok: ["A","downsampling","layer","with","an","optional","convolution",".",":","param","channels",":","channels","in","the","inputs","and","outputs",".",":","param","use_conv",":","a","bool","determining","if","a","convolution","is","applied","."]
code: def __init__(
      self,
      channels,
      use_conv,
      out_channels=None,
      factor=4,
      ksize=5,
      pad=2,
  ):
      super().__init__()
      self.channels = channels
      self.out_channels = out_channels or channels
      self.use_conv = use_conv
  
      stride = factor
      if use_conv:
          self.op = nn.Conv1d(
              self.channels,
              self.out_channels,
              ksize,
              stride=stride,
              padding=pad,
          )
      else:
          assert self.channels == self.out_channels
          self.op = nn.AvgPool1d(kernel_size=stride, stride=stride)
  
imports: import functools
  import math
  import os
  import fsspec
  import torch
  import torch.nn
  import torch.nn.functional
  import torchaudio
  from transformers import LogitsWarper
  from TTS.tts.layers.tortoise.xtransformers import ContinuousTransformerWrapper, RelativePositionBias
label_desc: Use image node_id 1 to create a new Downsample object from inherited base classes: nn with example: obj = Downsample(channels, use_conv, out_channels, factor, ksize, pad)