code: def redshift(distance, **kwargs):
      r
      cosmology = get_cosmology(**kwargs)
      try:
          z = _d2zs[cosmology.name](distance)
      except KeyError:
          # not a standard cosmology, call the redshift function
          z = _redshift(distance, cosmology=cosmology)
      return z
docs: r"""Returns the redshift associated with the given luminosity distance.
  
      If the requested cosmology is one of the pre-defined ones in
      :py:attr:`astropy.cosmology.parameters.available`, :py:class:`DistToZ` is
      used to provide a fast interpolation. This takes a few seconds to setup
      on the first call.
  
      Parameters
      ----------
      distance : float
          The luminosity distance, in Mpc.
      \**kwargs :
          All other keyword args are passed to :py:func:`get_cosmology` to
          select a cosmology. If none provided, will use
          :py:attr:`DEFAULT_COSMOLOGY`.
  
      Returns
      -------
      float :
          The redshift corresponding to the given distance.