code: def to_n_channels(waveform: tf.Tensor, n_channels: int) -> tf.Tensor:
      """
      Convert a waveform to n_channels by removing or duplicating channels if
      needed (in tensorflow).
  
      Parameters:
          waveform (tf.Tensor):
              Waveform to transform.
          n_channels (int):
              Number of channel to reshape waveform in.
  
      Returns:
          tf.Tensor:
              Reshaped waveform.
      """
      return tf.cond(
          tf.shape(waveform)[1] >= n_channels,
          true_fn=lambda: waveform[:, :n_channels],
          false_fn=lambda: tf.tile(waveform, [1, n_channels])[
              :, :n_channels
          ],
      )
  
file_path: spleeter/spleeter/audio/convertor.py
imports: import numpy
  import tensorflow
  from ..utils.tensor import from_float32_to_uint8, from_uint8_to_float32
label_desc: Use image node_id 1 for calling a global function with example usage: to_n_channels(waveform, n_channels) and returns: tf