code: def create_mask_and_seq_lens(
      episode_lens: List[int],
      T: int,
  ) -> Tuple[np._typing.NDArray, np._typing.NDArray]:
      """Creates loss mask and a seq_lens array, given a list of episode lengths and T.
  
      Args:
          episode_lens: A list of episode lengths to infer the loss mask and seq_lens
              array from.
          T: The maximum number of timesteps in each "row", also known as the maximum
              sequence length (max_seq_len). Episodes are split into chunks that are at
              most `T` long and remaining timesteps will be zero-padded (and masked out).
  
      Returns:
           Tuple consisting of a) the loss mask to use (masking out areas that are past
           the end of an episode (or rollout), but had to be zero-added due to the added
           extra time rank (of length T) and b) the array of sequence lengths resulting
           from splitting the given episodes into chunks of at most `T` timesteps.
      """
      mask = []
      seq_lens = []
      for episode_len in episode_lens:
          len_ = min(episode_len, T)
          seq_lens.append(len_)
          row = [1] * len_ + [0] * (T - len_)
          mask.append(row)
  
          # Handle sequence lengths greater than T.
          overflow = episode_len - T
          while overflow > 0:
              len_ = min(overflow, T)
              seq_lens.append(len_)
              extra_row = [1] * len_ + [0] * (T - len_)
              mask.append(extra_row)
              overflow -= T
  
      return np.array(mask, dtype=np.bool_), np.array(
          seq_lens, dtype=np.int32
      )
  
imports: from typing import List, Tuple
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: create_mask_and_seq_lens(episode_lens, T) and returns: np,  np