code: def __init__(
      self,
      model,
      layer_name,
      obses,
      obses_full=None,
      features=10,
      *,
      attr_layer_name=None,
      attr_opts={"integrate_steps": 10},
  ):
      self.model = model
      self.layer_name = layer_name
      self.obses = obses
      self.obses_full = obses_full
      if self.obses_full is None:
          self.obses_full = obses
      self.features = features
      self.pad_h = 0
      self.pad_w = 0
      self.padded_obses = self.obses_full
      if self.features is None:
          self.reducer = None
      else:
          self.reducer = ChannelReducer(features)
      acts = get_acts(model, layer_name, obses)
      self.patch_h = self.obses_full.shape[1] / acts.shape[1]
      self.patch_w = self.obses_full.shape[2] / acts.shape[2]
      if self.reducer is None:
          self.acts_reduced = acts
          self.channel_dirs = np.eye(self.acts_reduced.shape[-1])
          self.transform = lambda acts: acts.copy()
          self.inverse_transform = lambda acts: acts.copy()
      else:
          if attr_layer_name is None:
              self.acts_reduced = self.reducer.fit_transform(acts)
          else:
              attrs = get_attr(
                  model, attr_layer_name, layer_name, obses, **attr_opts
              )
              attrs_signed = np.concatenate(
                  [np.maximum(0, attrs), np.maximum(0, -attrs)], axis=0
              )
              self.reducer.fit(attrs_signed)
              self.acts_reduced = self.reducer.transform(acts)
          self.channel_dirs = self.reducer._reducer.components_
          self.transform = lambda acts: self.reducer.transform(acts)
          self.inverse_transform = (
              lambda acts_r: ChannelReducer._apply_flat(
                  self.reducer._reducer.inverse_transform, acts_r
              )
          )
  
file_path: lucid/lucid/scratch/rl_util/nmf.py
imports: import numpy
  from functools import reduce
  import scipy.ndimage
  from lucid.misc.channel_reducer import ChannelReducer
  import lucid.optvis.param
  import lucid.optvis.objectives
  import lucid.optvis.render
  import lucid.optvis.transform
  from .attribution import get_acts, get_attr
label_desc: Use image node_id 1 to create a new LayerNMF object  with example: obj = LayerNMF(model, layer_name, obses, obses_full, features)