code: def convert_tensor_encoding(
      tensor: torch.tensor,
      dtype: torch.dtype,
  ):
      """Convert input tensor with values between -1 and 1 to integer encoding
      Args:
          tensor: input tensor, assumed between -1 and 1
          dtype: desired output tensor dtype
      Returns:
          Tensor: shape of (n_channels, sample_rate * duration)
      """
      if dtype == torch.int32:
          tensor *= (tensor > 0) * 2147483647 + (
              tensor < 0
          ) * 2147483648
      if dtype == torch.int16:
          tensor *= (tensor > 0) * 32767 + (tensor < 0) * 32768
      if dtype == torch.uint8:
          tensor *= (tensor > 0) * 127 + (tensor < 0) * 128
          tensor += 128
      tensor = tensor.to(dtype)
      return tensor
  
file_path: audio/test/torchaudio_unittest/common_utils/data_utils.py
imports: import os.path
  from typing import Optional, Union
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: convert_tensor_encoding(tensor, dtype) and returns: tensor