code: def batch_frexp(inputs, max_bit=31):
      """
      Decompose the scaling factor into mantissa and twos exponent.
  
      Args:
          scaling_factor (`torch.Tensor`):
              Target scaling factor to decompose.
  
      Returns:
          ``Tuple(torch.Tensor, torch.Tensor)`: mantisa and exponent
      """
  
      shape_of_input = inputs.size()
  
      # trans the input to be a 1-d tensor
      inputs = inputs.view(-1)
  
      output_m, output_e = np.frexp(inputs.cpu().numpy())
      tmp_m = []
      for m in output_m:
          int_m_shifted = int(
              decimal.Decimal(m * (2**max_bit)).quantize(
                  decimal.Decimal("1"), rounding=decimal.ROUND_HALF_UP
              )
          )
          tmp_m.append(int_m_shifted)
      output_m = np.array(tmp_m)
  
      output_e = float(max_bit) - output_e
  
      return (
          torch.from_numpy(output_m)
          .to(inputs.device)
          .view(shape_of_input),
          torch.from_numpy(output_e)
          .to(inputs.device)
          .view(shape_of_input),
      )
  
imports: import decimal
  import numpy
  import torch
  from torch import nn
  from torch.autograd import Function
  from ...utils import logging
label_desc: Use image node_id 4 for calling a global function with example usage: batch_frexp(inputs, max_bit) and returns: torch,  torch