code: def activations_torch(model, X, fmt="longform", plot="boxplot"):
      X = torch.Tensor(X)
      if fmt == "longform":
          data = {"x": [], "weight": []}
      elif fmt == "summary":
          data = []
  
      partial_model = torch.nn.Sequential
      layers = []
      for layer in model.children():
          lname = layer.__class__.__name__
          layers.append(layer)
          pm = partial_model(*layers)
          print(f"   {lname}")
          y = pm(X).flatten().detach().numpy()
          y = abs(y[y != 0])
          if len(y) == 0:
              print(
                  f"Activations for {lname} are only zeros, ignoring."
              )
              continue
          if fmt == "longform":
              data["x"].extend(y.tolist())
              data["weight"].extend([lname for _ in range(len(y))])
          elif fmt == "summary":
              data.append(array_to_summary(y, fmt=plot))
              data[-1]["weight"] = lname
  
      if fmt == "longform":
          data = pandas.DataFrame(data)
      return data
  
imports: import json
  import os
  import shutil
  import uuid
  from collections import defaultdict
  import matplotlib.pyplot
  import numpy
  import pandas
  import seaborn
  from hls4ml.model.graph import ModelGraph
  from hls4ml.model.layers import GRU, LSTM, SeparableConv1D, SeparableConv2D
label_desc: Use image node_id 18 for calling a global function with example usage: activations_torch(model, X, fmt, plot) and returns: data