code: def linspace(
      start: Union[JaxArray, float],
      stop: float,
      /,
      num: int,
      *,
      axis: Optional[int] = None,
      endpoint: bool = True,
      dtype: jnp.dtype,
      device: jaxlib.xla_extension.Device = None,
      out: Optional[JaxArray] = None,
  ) -> JaxArray:
      if axis is None:
          axis = -1
  
      if num < 0:
          raise ivy.utils.exceptions.IvyException(
              f"Number of samples, {num}, must be non-negative."
          )
  
      if dtype is None:
          dtype = ivy.promote_types(start.dtype, stop.dtype)
      dtype = jnp.dtype(dtype)
      computation_dtype = dtype
      start = jnp.asarray(start, dtype=computation_dtype)
      stop = jnp.asarray(stop, dtype=computation_dtype)
  
      bounds_shape = list(
          jax.lax.broadcast_shapes(jnp.shape(start), jnp.shape(stop))
      )
      broadcast_start = jnp.broadcast_to(start, bounds_shape)
      broadcast_stop = jnp.broadcast_to(stop, bounds_shape)
      axis = len(bounds_shape) + axis + 1 if axis < 0 else axis
      bounds_shape.insert(axis, 1)
      div = (num - 1) if endpoint else num
      if num > 1:
          iota_shape = [
              1,
          ] * len(bounds_shape)
          iota_shape[axis] = div
          # This approach recovers the endpoints with float32 arithmetic,
          # but can lead to rounding errors for integer outputs.
          real_dtype = jnp.finfo(computation_dtype).dtype
          step = (
              jnp.reshape(jax.lax.iota(real_dtype, div), iota_shape)
              / div
          )
          step = step.astype(computation_dtype)
          start_reshaped = jnp.reshape(broadcast_start, bounds_shape)
          end_reshaped = jnp.reshape(broadcast_stop, bounds_shape)
          out = start_reshaped + step * (end_reshaped - start_reshaped)
  
          if endpoint:
              out = jax.lax.concatenate(
                  [out, jax.lax.expand_dims(broadcast_stop, (axis,))],
                  _src.util.canonicalize_axis(axis, out.ndim),
              )
  
      elif num == 1:
          out = jnp.reshape(broadcast_start, bounds_shape)
      else:  # num == 0 degenerate case, match numpy behavior
          empty_shape = list(
              jax.lax.broadcast_shapes(
                  jnp.shape(start), jnp.shape(stop)
              )
          )
          empty_shape.insert(axis, 0)
          out = jnp.reshape(jnp.array([], dtype=dtype), empty_shape)
  
      if jnp.issubdtype(dtype, jnp.integer) and not jnp.issubdtype(
          out.dtype, jnp.integer
      ):
          out = jax.lax.floor(out)
  
      ans = jax.lax.convert_element_type(out, dtype)
  
      return ans
  
imports: from numbers import Number
  import numpy
  from typing import Union, Optional, List, Sequence, Tuple
  import jax.dlpack
  import jax.numpy
  import jax._src
  import jaxlib.xla_extension
  import ivy
  from ivy import as_native_dtype
  from ivy.functional.backends.jax import JaxArray
  from ivy.functional.backends.jax.device import dev
  from ivy.functional.ivy.creation import _asarray_to_native_arrays_and_back, _asarray_infer_device, _asarray_infer_dtype, _asarray_handle_nestable, NestedSequence, SupportsBufferProtocol, _asarray_inputs_to_native_shapes
label_desc: Use image node_id 10 for calling a global function with example usage: linspace(num) and returns: ans