def METHOD_NAME(
    self, mini_batch_demo: AgentBuffer, n_sequences: int
) -> Dict[str, float]:
    """
    Helper function for update_batch.
    """
    np_obs = ObsUtil.from_buffer(
        mini_batch_demo, len(self.policy.behavior_spec.observation_specs)
    )
    # Convert to tensors
    tensor_obs = [ModelUtils.list_to_tensor(obs) for obs in np_obs]
    act_masks = None
    expert_actions = AgentAction.from_buffer(mini_batch_demo)
    if self.policy.behavior_spec.action_spec.discrete_size > 0:
        act_masks = ModelUtils.list_to_tensor(
            np.ones(
                (
                    self.n_sequences * self.policy.sequence_length,
                    sum(self.policy.behavior_spec.action_spec.discrete_branches),
                ),
                dtype=np.float32,
            )
        )
    memories = []
    if self.policy.use_recurrent:
        memories = torch.zeros(1, self.n_sequences, self.policy.m_size)
    selected_actions, run_out, _ = self.policy.actor.get_action_and_stats(
        tensor_obs,
        masks=act_masks,
        memories=memories,
        sequence_length=self.policy.sequence_length,
    )
    log_probs = run_out["log_probs"]
    bc_loss = self._behavioral_cloning_loss(
        selected_actions, log_probs, expert_actions
    )
    self.optimizer.zero_grad()
    bc_loss.backward()
    self.optimizer.step()
    run_out = {"loss": bc_loss.item()}
    return run_out