code: def extract_children_states_from_actions(
      state: torch.Tensor,
      actions: torch.Tensor,
      vec_cardinality: int = 5,
  ):
      """Extract the children states from the actions.
  
      Args:
          state (torch.Tensor): The state of the game.
          actions (torch.Tensor): The actions to apply to the state.
          vec_cardinality (int, optional): The cardinality of the vectors.
      """
      # state (1, T, S, S, S)
      # actions (1, K, N_steps)
      # we assume actions to be with N_steps = 1,
      #  and N_logits = |F|^(3S/N_steps). Each action is then mapped in a
      #  unique way to a triplet (u, v, w) where each vector has size S.
      # vector cardinality represents the number of values it can take an entry
      #  of u, v or w.
      bs, k, n_steps = actions.shape[:3]
      len_token = 3 * state.shape[2] // n_steps
      actions = map_action_to_triplet(
          actions, vec_cardinality, len_token
      )
      actions = actions.reshape(bs, k, n_steps * len_token)
      vec_dim = state.shape[2]
      u = actions[:, :, :vec_dim].reshape(bs, k, vec_dim, 1, 1)
      v = actions[:, :, vec_dim : 2 * vec_dim].reshape(  # noqa E203
          bs, k, 1, vec_dim, 1
      )
      w = actions[:, :, 2 * vec_dim :].reshape(
          bs, k, 1, 1, vec_dim
      )  # noqa E203
      reducing_tensor = u * v * w
      (
          reducing_tensor,
          old_idx_to_new_idx,
          repetition_map,
          not_duplicate_indexes,
      ) = remove_duplicates(reducing_tensor)
      old_state = state[:, 0]
      new_state = old_state.unsqueeze(1) - reducing_tensor
      rolling_states = torch.roll(state, 1)[:, 2:]
      return (
          [
              torch.cat(
                  [
                      new_state[:, i : i + 1],  # noqa E203
                      reducing_tensor[:, i : i + 1],  # noqa E203
                      rolling_states,
                  ],
                  dim=1,
              )
              for i in range(k)
          ],
          old_idx_to_new_idx,
          repetition_map,
          not_duplicate_indexes,
      )
  
file_path: nebuly/optimization/open_alpha_tensor/open_alpha_tensor/core/actors/stage.py
imports: from typing import Dict, List
  import torch
  from open_alpha_tensor.core.data.utils import get_scalars, map_action_to_triplet
  from open_alpha_tensor.core.modules.alpha_tensor import AlphaTensorModel
label_desc: Use image node_id 3 for calling a global function with example usage: extract_children_states_from_actions(state, actions, vec_cardinality) and returns: unknown,  old_idx_to_new_idx,  repetition_map,  not_duplicate_indexes