code: def mu_law_encoding(x: Tensor, quantization_channels: int) -> Tensor:
      r"""Encode signal based on mu-law companding.
  
      .. devices:: CPU CUDA
  
      .. properties:: TorchScript
  
      For more info see the
      `Wikipedia Entry <https://en.wikipedia.org/wiki/%CE%9C-law_algorithm>`_
  
      This algorithm expects the signal has been scaled to between -1 and 1 and
      returns a signal encoded with values from 0 to quantization_channels - 1.
  
      Args:
          x (Tensor): Input tensor
          quantization_channels (int): Number of channels
  
      Returns:
          Tensor: Input after mu-law encoding
      """
      mu = quantization_channels - 1.0
      if not x.is_floating_point():
          warnings.warn(
              "The input Tensor must be of floating type. \
              This will be an error in the v0.12 release."
          )
          x = x.to(torch.float)
      mu = torch.tensor(mu, dtype=x.dtype)
      x_mu = (
          torch.sign(x)
          * torch.log1p(mu * torch.abs(x))
          / torch.log1p(mu)
      )
      x_mu = ((x_mu + 1) / 2 * mu + 0.5).to(torch.int64)
      return x_mu
  
imports: import math
  import tempfile
  import warnings
  from collections.abc import Sequence
  from typing import List, Optional, Tuple, Union
  import torch
  import torchaudio
  from torch import Tensor
  from torchaudio._internal.module_utils import deprecated
  from .filtering import highpass_biquad, treble_biquad
label_desc: Use image node_id 14 for calling a global function with example usage: mu_law_encoding(x, quantization_channels) and returns: x_mu