def prepare_feed_dict(model, features, labels=None, is_training=None):
    """Prepares a feed_dict for sess.run() given a batch of features and labels.

  Args:
    model: An instance of AstroModel.
    features: Dictionary containing "time_series_features" and "aux_features".
        Each is a dictionary of named numpy arrays of shape
        [batch_size, length].
    labels: (Optional). Numpy array of shape [batch_size].
    is_training: (Optional). Python boolean to feed to the model.is_training
        Tensor (if None, no value is fed).

  Returns:
    feed_dict: A dictionary of input Tensor to numpy array.
  """
    feed_dict = {}
    for feature, tensor in model.time_series_features.items():
        feed_dict[tensor] = features["time_series_features"][feature]
    for feature, tensor in model.aux_features.items():
        feed_dict[tensor] = features["aux_features"][feature]

    if labels is not None:
        feed_dict[model.labels] = labels

    if is_training is not None:
        feed_dict[model.is_training] = is_training

    return feed_dict