code: def qr(a):
      """
      Compute the qr factorization of a matrix.
  
      Parameters
      ----------
      a : Array
  
      Returns
      -------
      q:  Array, orthonormal
      r:  Array, upper-triangular
  
      Examples
      --------
      >>> q, r = da.linalg.qr(x)  # doctest: +SKIP
  
      See Also
      --------
      numpy.linalg.qr: Equivalent NumPy Operation
      dask.array.linalg.tsqr: Implementation for tall-and-skinny arrays
      dask.array.linalg.sfqr: Implementation for short-and-fat arrays
      """
  
      if len(a.chunks[1]) == 1 and len(a.chunks[0]) > 1:
          return tsqr(a)
      elif len(a.chunks[0]) == 1:
          return sfqr(a)
      else:
          raise NotImplementedError(
              "qr currently supports only tall-and-skinny (single column chunk/block; see tsqr)\n"
              "and short-and-fat (single row chunk/block; see sfqr) matrices\n\n"
              "Consider use of the rechunk method. For example,\n\n"
              "x.rechunk({0: -1, 1: 'auto'}) or x.rechunk({0: 'auto', 1: -1})\n\n"
              "which rechunk one shorter axis to a single chunk, while allowing\n"
              "the other axis to automatically grow/shrink appropriately."
          )
  
imports: from __future__ import annotations
  import operator
  import warnings
  from functools import partial
  from numbers import Number
  import numpy
  import tlz
  from dask.array.core import Array, concatenate, dotmany, from_delayed
  from dask.array.creation import eye
  from dask.array.random import RandomState, default_rng
  from dask.array.utils import array_safe, meta_from_array, solve_triangular_safe, svd_flip
  from dask.base import tokenize, wait
  from dask.blockwise import blockwise
  from dask.delayed import delayed
  from dask.highlevelgraph import HighLevelGraph
  from dask.utils import apply, derived_from
label_desc: Use image node_id 10 for calling a global function with example usage: qr(a) and returns: tsqr, sfqr