code: def _scale(a, n, m, copy=True):
      """Scale an array of unsigned/positive integers from `n` to `m` bits.
      Numbers can be represented exactly only if `m` is a multiple of `n`.
      Parameters
      ----------
      a : ndarray
          Input image array.
      n : int
          Number of bits currently used to encode the values in `a`.
      m : int
          Desired number of bits to encode the values in `out`.
      copy : bool, optional
          If True, allocates and returns new array. Otherwise, modifies
          `a` in place.
      Returns
      -------
      out : array
          Output image array. Has the same kind as `a`.
      """
      kind = a.dtype.kind
      if n > m and a.max() < 2**m:
          mnew = int(np.ceil(m / 2) * 2)
          if mnew > m:
              dtype = "int{}".format(mnew)
          else:
              dtype = "uint{}".format(mnew)
          n = int(np.ceil(n / 2) * 2)
          warn(
              "Downcasting {} to {} without scaling because max "
              "value {} fits in {}".format(
                  a.dtype, dtype, a.max(), dtype
              ),
              stacklevel=3,
          )
          return a.astype(_dtype_bits(kind, m))
      elif n == m:
          return a.copy() if copy else a
      elif n > m:
          # downscale with precision loss
          if copy:
              b = np.empty(a.shape, _dtype_bits(kind, m))
              np.floor_divide(
                  a,
                  2 ** (n - m),
                  out=b,
                  dtype=a.dtype,
                  casting="unsafe",
              )
              return b
          else:
              a //= 2 ** (n - m)
              return a
      elif m % n == 0:
          # exact upscale to a multiple of `n` bits
          if copy:
              b = np.empty(a.shape, _dtype_bits(kind, m))
              np.multiply(
                  a, (2**m - 1) // (2**n - 1), out=b, dtype=b.dtype
              )
              return b
          else:
              a = a.astype(
                  _dtype_bits(kind, m, a.dtype.itemsize), copy=False
              )
              a *= (2**m - 1) // (2**n - 1)
              return a
      else:
          # upscale to a multiple of `n` bits,
          # then downscale with precision loss
          o = (m // n + 1) * n
          if copy:
              b = np.empty(a.shape, _dtype_bits(kind, o))
              np.multiply(
                  a, (2**o - 1) // (2**n - 1), out=b, dtype=b.dtype
              )
              b //= 2 ** (o - m)
              return b
          else:
              a = a.astype(
                  _dtype_bits(kind, o, a.dtype.itemsize), copy=False
              )
              a *= (2**o - 1) // (2**n - 1)
              a //= 2 ** (o - m)
              return a
  
imports: import numpy
  from scipy import linalg
  from warnings import warn
label_desc: Use image node_id 15 for calling a global function with example usage: _scale(a, n, m, copy) and returns: a, unknown, b, a, b, a, b, a