code: def shifted_range_origin(mapping, difference_vector, new_origin):
      """Shift the origin of the range.
  
      Parameters
      ----------
      difference_vector : array
         Representing the difference shifted_origin-current_origin in the
         range's basis.
  
      Examples
      --------
      >>> A = np.random.standard_normal((5,6))
      >>> A[-1] = [0,0,0,0,0,1]
      >>> affine_transform = AffineTransform(CS('ijklm'), CS('xyzt', 'oldorigin'), A)
      >>> affine_transform.function_range
      CoordinateSystem(coord_names=('x', 'y', 'z', 't'), name='oldorigin', coord_dtype=float64)
  
      Make a random shift of the origin in the range
  
      >>> difference = np.random.standard_normal(4)
      >>> shifted_affine_transform = shifted_range_origin(affine_transform, difference, 'neworigin')
      >>> shifted_affine_transform.function_range
      CoordinateSystem(coord_names=('x', 'y', 'z', 't'), name='neworigin', coord_dtype=float64)
      >>>
  
      Evaluate the transform and verify it does as expected
  
      >>> point_in_domain = np.random.standard_normal(5)
  
      Check that things work
  
      >>> np.allclose(shifted_affine_transform(point_in_domain), affine_transform(point_in_domain) - difference)
      True
      >>> np.allclose(shifted_affine_transform(point_in_domain) + difference, affine_transform(point_in_domain))
      True
      """
      new_function_range = CoordinateSystem(
          mapping.function_range.coord_names,
          new_origin,
          coord_dtype=mapping.function_range.coord_dtype,
      )
  
      ndim = new_function_range.ndim
      shift_matrix = np.identity(
          ndim + 1, mapping.function_range.coord_dtype
      )
      shift_matrix[:-1, -1] = -np.array(difference_vector)
      shift_map = AffineTransform(
          mapping.function_range, new_function_range, shift_matrix
      )
  
      if isinstance(mapping, AffineTransform):
          return _compose_affines(shift_map, mapping)
      else:
          return _compose_cmaps(_as_coordinate_map(shift_map), mapping)
  
imports: import warnings
  import numpy
  import numpy.linalg
  from nibabel import io_orientation
  from nibabel.affines import from_matvec, to_matvec
  from .coordinate_system import CoordinateSystem, is_coordsys, safe_dtype
  from .coordinate_system import product
label_desc: Use image node_id 5 for calling a global function with example usage: shifted_range_origin(mapping, difference_vector, new_origin) and returns: _compose_affines, _compose_cmaps