def global_skel_state_from_local_skel_state_impl(local_skel_state: Tensor,
    prefix_mul_indices: List[Tensor],
    save_intermediate_results: bool=True,
    use_double_precision: bool=True) -> Tuple[Tensor, List[Tensor]]:
  _0 = __torch__.pymomentum.skel_state.multiply
  dtype = ops.prim.dtype(local_skel_state)
  intermediate_results = annotate(List[Tensor], [])
  if use_double_precision:
    global_skel_state0 = torch.to(torch.clone(local_skel_state), 7)
    global_skel_state = global_skel_state0
  else:
    global_skel_state = torch.clone(local_skel_state)
  for _1 in range(torch.len(prefix_mul_indices)):
    prefix_mul_index = prefix_mul_indices[_1]
    source = torch.select(prefix_mul_index, 0, 0)
    target = torch.select(prefix_mul_index, 0, 1)
    state1 = torch.index_select(global_skel_state, -2, target)
    state2 = torch.index_select(global_skel_state, -2, source)
    if save_intermediate_results:
      _2 = torch.append(intermediate_results, torch.clone(state2))
    else:
      pass
    _3 = torch.index_copy_(global_skel_state, -2, source, _0(state1, state2, ))
  _4 = (torch.to(global_skel_state, dtype), intermediate_results)
  return _4
def skin_points_from_skel_state(template: Tensor,
    global_skel_state: Tensor,
    binded_skel_state_inv: Tensor,
    skin_indices_flattened: Tensor,
    skin_weights_flattened: Tensor,
    vert_indices_flattened: Tensor) -> Tensor:
  _5 = __torch__.pymomentum.skel_state.multiply
  _6 = __torch__.pymomentum.skel_state.transform_points
  _7 = torch.eq((torch.size(template))[-1], 3)
  if _7:
    pass
  else:
    ops.prim.RaiseException("AssertionError: ")
  _8 = torch.lt(torch.dim(template), torch.dim(global_skel_state))
  template0 = template
  _9 = _8
  while _9:
    template1 = torch.unsqueeze(template0, 0)
    _10 = torch.lt(torch.dim(template1), torch.dim(global_skel_state))
    _9, template0 = _10, template1
  _11 = torch.slice(torch.size(global_skel_state), None, -2)
  _12 = torch.list(_11)
  _13 = torch.slice(torch.size(template0), -2)
  template2 = torch.expand(template0, torch.add(_12, torch.list(_13)))
  joint_state = _5(global_skel_state, binded_skel_state_inv, )
  skinned = torch.zeros_like(template2)
  _14 = torch.index_select(joint_state, -2, skin_indices_flattened)
  _15 = torch.index_select(template2, -2, vert_indices_flattened)
  _16 = _6(_14, _15, )
  _17 = torch.unsqueeze(skin_weights_flattened, 0)
  _18 = torch.unsqueeze(torch.slice(_17, 1), 2)
  skinned0 = torch.index_add(skinned, -2, vert_indices_flattened, torch.mul(_16, _18))
  return skinned0
