<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _last_index(x, default_dim):
 """Returns the last dimension's index or default_dim if x has no shape."""

  if x.get_shape().ndims is not None:
    return len(x.get_shape()) - 1
  else:
    return default_dim