def _get_batch_size(params, hparams, config):
    """Batch size determined by params dict, HParams, and RunConfig."""
    batch_size = params and params.get('batch_size')
    if not batch_size:
        batch_size = hparams.tpu_batch_size_per_shard
        if config:
            batch_size *= config.t2t_device_info['num_shards']
    return batch_size
