<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def one_hot(indices, output_dim, on_value=1.0, off_value=0.0, dtype=tf.float32, name=None):
 """One hot operation. TODO(noam):
 Is there a good reason we need a special mtf.Operation here? We could just use some code like this: cast(equal(indices, mtf_range(indices.mesh, output_dim, dtype=indices.dtype)), dtype) Args: indices: a Tensor output_dim: a Dimension on_value: Value taken when indices are on at a location, default 1 off_value: Value taken when indices are off at a location, default 0 dtype: a tf.DType name: an optional string Returns: a Tensor with shape extended by output_dim for the last axis. """

  return OneHotOperation(
      indices, output_dim, on_value, off_value, dtype, name=name).outputs[0]