class_docstr: ## Configurations
  
  The default configs can and will be over-ridden when we start the experiment
docstr: Concatenate memories and remove old memories to keep a maximum of
  `mem_len` memories.
docstr_tok: ["Concatenate","memories","and","remove","old","memories","to","keep","a","maximum","of","`","mem_len","`","memories","."]
code: def merge_memory(self, old_mem, new_mem):
      """
      Concatenate memories and remove old memories to keep a maximum of
      `mem_len` memories.
      """
  
      # If it's configured not to use memory
      if self.mem_len == 0:
          return []
  
      # Concatenate with old memory
      if old_mem:
          mem = [
              torch.cat((m, x), dim=0) for m, x in zip(old_mem, new_mem)
          ]
      else:
          mem = new_mem
  
      # Truncate old memories
      if len(mem[0]) > self.mem_len:
          mem = [m[-self.mem_len :] for m in mem]
  
      #
      return mem
  
imports: from typing import List
  import torch
  import torch.nn
  from labml.logger import Text
  from labml import experiment, tracker, monit, logger
  from labml.configs import option
  from labml_helpers.metrics.simple_state import SimpleStateModule
  from labml_helpers.module import Module
  from labml_helpers.train_valid import BatchIndex, hook_model_outputs
  from labml_nn.experiments.nlp_autoregression import NLPAutoRegressionConfigs
  from labml_nn.transformers.xl import TransformerXL, TransformerXLLayer
label_desc: Use image node_id 2 for calling the Configs obj's underlying member method code with example usage: obj.merge_memory(old_mem, new_mem) and returns: mem, list