(x_tuple)
return fastmath.nested_map(f, x_tuple)
Combines multi-device tensors into a single batch.
Combines multi-device tensors into a single batch.
Combines multi - device tensors into a single batch .
def _combine_devices(x_tuple):
  """Combines multi-device tensors into a single batch."""
  def f(x):
    if len(x.shape) < 2:
      return x  # No extra batch dimension: use devices as batch, so return.
    batch_size = x.shape[0] * x.shape[1]
    return jnp.reshape(x, [batch_size] + list(x.shape[2:]))
  return fastmath.nested_map(f, x_tuple)
def _combine_devices ( x_tuple ) : def f ( x ) : if len ( x . shape ) < 2 : return x # No extra batch dimension: use devices as batch, so return. batch_size = x . shape [ 0 ] * x . shape [ 1 ] return jnp . reshape ( x , [ batch_size ] + list ( x . shape [ 2 : ] ) ) return fastmath . nested_map ( f , x_tuple )