def convert_to_tuple_of_two_int(value, name):
  """Transforms iterable of 2 integers into an tuple of 2 integers.

  Args:
    value: A iterable of 2 ints.
    name: The name of the argument being validated, e.g., sparsity_m_by_n.

  Returns:
    A tuple of 2 integers.

  Raises:
    ValueError: If something else than an iterable of ints was passed.
  """
  try:
    value_tuple = tuple(value)
  except TypeError:
    raise ValueError(f"The {name} argument must be a tuple/list of 2 integers."
                     f"received: {str(value)}.") from None
  if len(value_tuple) != 2:
    raise ValueError(f"The {name} argument must be a tuple/list of 2 integers."
                     f"received: {str(value)}.")
  for single_value in value_tuple:
    if not isinstance(single_value, int):
      raise ValueError(
          f"The {name} argument must be a tuple/list of 2 integers."
          f"received: {str(value)} including element {str(single_value)} "
          f"of type {str(type(single_value))}.")

  return value_tuple