Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inputting nuclei counts into cell2location #344

Open
ssobt opened this issue Jan 18, 2024 · 21 comments
Open

Inputting nuclei counts into cell2location #344

ssobt opened this issue Jan 18, 2024 · 21 comments

Comments

@ssobt
Copy link

ssobt commented Jan 18, 2024

Hi, thank you for this tool! I have a question about entering in cell counts. I’m using an older version of cell2location (v.02-alpha) to input in nuclei counts for the 'the expected number of cells per location' hyperparamter. We’re having some trouble getting the latest version (v.0.1.3) to assign cell probabilities to most of the tissue due to high RNA variability after trying both 20 and 200 for alpha (see image below for alpha 200). Areas with low RNA content have very low probabilities assigned for any of the reference cell types. To try to alleviate the problem, we switched to the older version to input custom cell/nuclei counts. In v.02-alpha, I have inputted in a 1-dimensional numpy array with the nuclei counts of each spot (made from concatenating rows of 2d x,y array) on the Visium slide, the following error occurs asking for one value instead of locations specific values: Gamma has no finite default value to use, checked: ('median', 'mean', 'mode'). Pass testval argument or adjust so value is finite.

I tried entering the 2d array directly and got the same error. The model only started to run when I entered one integer, so I was wondering how to input nuclei counts per each spot/location? Any advice on this would be great, thanks!

image

Here is the model setup:

nuclei_count_1d = np.array(nuclei_counts_1149G['Count'])
r = cell2location.run_cell2location(

      # Single cell reference signatures as pd.DataFrame
      # (could also be data as anndata object for estimating signatures
      #  as cluster average expression - `sc_data=adata_snrna_raw`)
      sc_data=inf_aver,
      # Spatial data as anndata object
      sp_data=slide,

      # the column in sc_data.obs that gives cluster idenitity of each cell
      summ_sc_data_args={'cluster_col': "annotation_1",
                        },

      train_args={'use_raw': True, # By default uses raw slots in both of the input datasets.
                  'n_iter': 40000, # Increase the number of iterations if needed (see QC below)

                  # Whe analysing the data that contains multiple experiments,
                  # cell2location automatically enters the mode which pools information across experiments
                  'sample_name_col': 'sample'}, # Column in sp_data.obs with experiment ID (see above)


      export_args={'path': results_folder, # path where to save results
                   'save_model': True,
                   'run_name_suffix': '' # optinal suffix to modify the name the run
                  },

      model_kwargs={ # Prior on the number of cells, cell types and co-located groups

                    'cell_number_prior': {
                        # - N - the expected number of cells per location:
                        'cells_per_spot': nuclei_count_1d, # < - change this
                        # - A - the expected number of cell types per location (use default):
                        'factors_per_spot': 7,
                        # - Y - the expected number of co-located cell type groups per location (use default):
                        'combs_per_spot': 7
                    },

                     # Prior beliefs on the sensitivity of spatial technology:
                    'gene_level_prior':{
                        # Prior on the mean
                        'mean': 1/2,
                        # Prior on standard deviation,
                        # a good choice of this value should be at least 2 times lower that the mean
                        'sd': 1/4
                    }
      }
)

@ssobt ssobt added the bug Something isn't working label Jan 18, 2024
@vitkl
Copy link
Contributor

vitkl commented Jan 18, 2024

Hi @ssobt

Looks like the main issue is indeed that a sample has many areas have very low counts. I would address that issue rather than figuring out how to input nuclei counts.

  1. Does nuclei count distribution have a similar distribution to total RNA count? If this is very different it suggests a strong technical effect.
  2. "Areas with low RNA content have very low probabilities assigned for any of the reference cell types." For areas that have little RNA content, as appears to be the case here, you don't necessarily have enough RNA to distinguish any cell type.
  3. Including nuclei count into cell2location would not solve the second problem.
  4. To address, the first problem you could try smaller detection_alpha 0.5 1 2 5. However, if the counts are too low to map anything you would just see noise/similar abundances of all cell types in all low count areas (problem 2).
  5. In projects that I worked on such as (Madissoon et al, we deleted samples with similarly high variability in total count and large areas of low RNA content.
  6. You could try deleting all locations with total RNA count < 1000 or a similar cutoff.

Please don't use older versions (cell2location.run_cell2location) because they are not supported and don't correspond to the published paper.

@vitkl
Copy link
Contributor

vitkl commented Jan 18, 2024

We don't support nuclei count use because we did not find providing that information useful in benchmarks and it is not available for many datasets. Does the analysis work well and provide the expected results with v.02-alpha?

That said, I don't see why providing a 2D shape=(obs, 1) array to N_cells_per_location should be a problem. What error do you see in the latest version?

@vitkl
Copy link
Contributor

vitkl commented Jan 18, 2024

Actually, I see a problem with the latest version. This line

self.detection_mean_ = (sp_total / model_kwargs.get("N_cells_per_location", 1)) / sc_total
needs to be changed to support both scalar values and arrays. Feel free to contribute a PR.

@ssobt
Copy link
Author

ssobt commented Jan 25, 2024

Hi, thanks for the quick response. I don't see why that line in the last comment would cause problems. It would be a scalar divided by an array divided by another scalar so detection_mean_ should come out as an array, which shouldn't be a problem, right?

For some of your questions:

  1. Yes, nuclei count is very similarly distributed to total RNA count
  2. That makes sense that there might not be enough RNA to make distinctions
  3. I figured, but I wanted to give it a try in case it might
  4. I tried running with alphas of 0.5 and 5 (see attached images) and both were very broad in calling 2-3 cell types for all the spots (overlapping calls) hinting to point number 2 above
  5. Hmm, this is the last resort but certainly on the table if nothing else works
  6. I think given the amount of tissue with lower RNA count (60-70%), it might be easier to simply get more samples

The results for v.02-alpha using a scalar value for 'cells_per_spot' wasn't able to call the low RNA content areas similar to the latest version. I tried running the latest version (v.0.1.3) with a dummy 1d array np.random.randint(1,4,2163) and 2d array np.random.randint(1,4,2163).reshape(2163,1) without any luck. The errors were different each time but I've put them both below. Is there anything I can do to remedy them since I don't think the line you mentioned is what's causing the problem, and thank you for taking such a thorough look at the data.

1d array error output
RuntimeError                              Traceback (most recent call last)
File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174), in TraceHandler.__call__(self, *args, **kwargs)
    [173](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:173) try:
--> [174](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174)     ret = self.fn(*args, **kwargs)
    [175](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:175) except (ValueError, RuntimeError) as e:

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12), in _context_wrap(context, fn, *args, **kwargs)
     [11](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:11) with context:
---> [12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12)     return fn(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12), in _context_wrap(context, fn, *args, **kwargs)
     [11](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:11) with context:
---> [12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12)     return fn(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448), in PyroModule.__call__(self, *args, **kwargs)
    [447](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:447) with self._pyro_context:
--> [448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448)     result = super().__call__(*args, **kwargs)
    [449](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:449) if (
    [450](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:450)     pyro.settings.get("validate_poutine")
    [451](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:451)     and not self._pyro_context.active
    [452](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:452)     and _is_module_local_param_enabled()
    [453](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:453) ):

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194), in Module._call_impl(self, *input, **kwargs)
   [1192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1192) if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   [1193](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1193)         or _global_forward_hooks or _global_forward_pre_hooks):
-> [1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194)     return forward_call(*input, **kwargs)
   [1195](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1195) # Do not call functions when jit is used

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:321](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:321), in LocationModelLinearDependentWMultiExperimentLocationBackgroundNormLevelGeneAlphaPyroModel.forward(self, x_data, idx, batch_index)
    [320](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:320) shape = self.ones_1_n_groups * b_s_groups_per_location [/](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/) self.n_groups_tensor
--> [321](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:321) rate = self.ones_1_n_groups [/](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/) (n_s_cells_per_location [/](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/) b_s_groups_per_location)
    [322](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:322) with obs_plate as ind:

RuntimeError: The size of tensor a (50) must match the size of tensor b (2163) at non-singleton dimension 1

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
Cell In[34], [line 1](vscode-notebook-cell:?execution_count=34&line=1)
----> [1](vscode-notebook-cell:?execution_count=34&line=1) mod.train(max_epochs=3000,
      [2](vscode-notebook-cell:?execution_count=34&line=2)           # train using full data (batch_size=None)
      [3](vscode-notebook-cell:?execution_count=34&line=3)           batch_size=None,
      [4](vscode-notebook-cell:?execution_count=34&line=4)           # use all data points in training because
      [5](vscode-notebook-cell:?execution_count=34&line=5)           # we need to estimate cell abundance at all locations
      [6](vscode-notebook-cell:?execution_count=34&line=6)           train_size=1,
      [7](vscode-notebook-cell:?execution_count=34&line=7)           use_gpu=False,
      [8](vscode-notebook-cell:?execution_count=34&line=8)          )
     [10](vscode-notebook-cell:?execution_count=34&line=10) # plot ELBO loss history during training, removing first 100 epochs from the plot
     [11](vscode-notebook-cell:?execution_count=34&line=11) mod.plot_history(1000)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:209](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:209), in Cell2location.train(self, max_epochs, batch_size, train_size, lr, num_particles, scale_elbo, **kwargs)
    [206](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:206)         scale_elbo = 1.0 [/](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/) (self.summary_stats["n_cells"] * self.summary_stats["n_vars"])
    [207](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:207)     kwargs["plan_kwargs"]["scale_elbo"] = scale_elbo
--> [209](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:209) super().train(**kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:178](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:178), in PyroSviTrainMixin.train(self, max_epochs, use_gpu, train_size, validation_size, batch_size, early_stopping, lr, training_plan, plan_kwargs, **trainer_kwargs)
    [168](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:168) trainer_kwargs["callbacks"].append(PyroJitGuideWarmup())
    [170](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:170) runner = self._train_runner_cls(
    [171](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:171)     self,
    [172](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:172)     training_plan=training_plan,
   (...)
    [176](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:176)     **trainer_kwargs,
    [177](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:177) )
--> [178](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:178) return runner()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:83](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:83), in TrainRunner.__call__(self)
     [80](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:80) if hasattr(self.data_splitter, "n_val"):
     [81](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:81)     self.training_plan.n_obs_validation = self.data_splitter.n_val
---> [83](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:83) self.trainer.fit(self.training_plan, self.data_splitter)
     [84](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:84) self._update_history()
     [86](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:86) # data splitter only gets these attrs after fit

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:194), in Trainer.fit(self, *args, **kwargs)
    [188](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:188) if isinstance(args[0], PyroTrainingPlan):
    [189](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:189)     warnings.filterwarnings(
    [190](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:190)         action="ignore",
    [191](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:191)         category=UserWarning,
    [192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:192)         message="`LightningModule.configure_optimizers` returned `None`",
    [193](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:193)     )
--> [194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:194) super().fit(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:608](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:608), in Trainer.fit(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
    [606](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:606)     raise TypeError(f"`Trainer.fit()` requires a `LightningModule`, got: {model.__class__.__qualname__}")
    [607](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:607) self.strategy._lightning_module = model
--> [608](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:608) call._call_and_handle_interrupt(
    [609](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:609)     self, self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path
    [610](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:610) )

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:38](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:38), in _call_and_handle_interrupt(trainer, trainer_fn, *args, **kwargs)
     [36](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:36)         return trainer.strategy.launcher.launch(trainer_fn, *args, trainer=trainer, **kwargs)
     [37](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:37)     else:
---> [38](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:38)         return trainer_fn(*args, **kwargs)
     [40](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:40) except _TunerExitException:
     [41](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:41)     trainer._call_teardown_hook()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:650](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:650), in Trainer._fit_impl(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
    [643](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:643) ckpt_path = ckpt_path or self.resume_from_checkpoint
    [644](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:644) self._ckpt_path = self._checkpoint_connector._set_ckpt_path(
    [645](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:645)     self.state.fn,
    [646](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:646)     ckpt_path,  # type: ignore[arg-type]
    [647](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:647)     model_provided=True,
    [648](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:648)     model_connected=self.lightning_module is not None,
    [649](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:649) )
--> [650](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:650) self._run(model, ckpt_path=self.ckpt_path)
    [652](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:652) assert self.state.stopped
    [653](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:653) self.training = False

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1103](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1103), in Trainer._run(self, model, ckpt_path)
   [1099](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1099) self._checkpoint_connector.restore_training_state()
   [1101](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1101) self._checkpoint_connector.resume_end()
-> [1103](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1103) results = self._run_stage()
   [1105](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1105) log.detail(f"{self.__class__.__name__}: trainer tearing down")
   [1106](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1106) self._teardown()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1182](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1182), in Trainer._run_stage(self)
   [1180](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1180) if self.predicting:
   [1181](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1181)     return self._run_predict()
-> [1182](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1182) self._run_train()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1205](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1205), in Trainer._run_train(self)
   [1202](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1202) self.fit_loop.trainer = self
   [1204](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1204) with torch.autograd.set_detect_anomaly(self._detect_anomaly):
-> [1205](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1205)     self.fit_loop.run()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:194), in Loop.run(self, *args, **kwargs)
    [190](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:190)     return self.on_skip()
    [192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:192) self.reset()
--> [194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:194) self.on_run_start(*args, **kwargs)
    [196](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:196) while not self.done:
    [197](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:197)     try:

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:217](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:217), in FitLoop.on_run_start(self)
    [214](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:214) self._is_fresh_start_epoch = True
    [215](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:215) self._results.to(device=self.trainer.lightning_module.device)
--> [217](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:217) self.trainer._call_callback_hooks("on_train_start")
    [218](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:218) self.trainer._call_lightning_module_hook("on_train_start")
    [219](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:219) self.trainer._call_strategy_hook("on_train_start")

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1385](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1385), in Trainer._call_callback_hooks(self, hook_name, *args, **kwargs)
   [1383](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1383)     if callable(fn):
   [1384](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1384)         with self.profiler.profile(f"[Callback]{callback.state_key}.{hook_name}"):
-> [1385](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1385)             fn(self, self.lightning_module, *args, **kwargs)
   [1387](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1387) if pl_module:
   [1388](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1388)     # restore current_fx when nested context
   [1389](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1389)     pl_module._current_fx_name = prev_fx_name

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:45](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:45), in PyroJitGuideWarmup.on_train_start(self, trainer, pl_module)
     [43](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:43) tens = {k: t.to(pl_module.device) for k, t in tensors.items()}
     [44](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:44) args, kwargs = pl_module.module._get_fn_args_from_batch(tens)
---> [45](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:45) pyro_guide(*args, **kwargs)
     [46](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:46) break

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448), in PyroModule.__call__(self, *args, **kwargs)
    [446](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:446) def __call__(self, *args, **kwargs):
    [447](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:447)     with self._pyro_context:
--> [448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448)         result = super().__call__(*args, **kwargs)
    [449](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:449)     if (
    [450](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:450)         pyro.settings.get("validate_poutine")
    [451](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:451)         and not self._pyro_context.active
    [452](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:452)         and _is_module_local_param_enabled()
    [453](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:453)     ):
    [454](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:454)         self._check_module_local_param_usage()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194), in Module._call_impl(self, *input, **kwargs)
   [1190](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1190) # If we don't have any hooks, we want to skip the rest of the logic in
   [1191](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1191) # this function, and just call forward.
   [1192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1192) if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   [1193](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1193)         or _global_forward_hooks or _global_forward_pre_hooks):
-> [1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194)     return forward_call(*input, **kwargs)
   [1195](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1195) # Do not call functions when jit is used
   [1196](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1196) full_backward_hooks, non_full_backward_hooks = [], []

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:510](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:510), in AutoNormal.forward(self, *args, **kwargs)
    [508](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:508) # if we've never run the model before, do so now so we can inspect the model structure
    [509](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:509) if self.prototype_trace is None:
--> [510](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:510)     self._setup_prototype(*args, **kwargs)
    [512](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:512) plates = self._create_plates(*args, **kwargs)
    [513](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:513) result = {}

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:460](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:460), in AutoNormal._setup_prototype(self, *args, **kwargs)
    [459](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:459) def _setup_prototype(self, *args, **kwargs):
--> [460](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:460)     super()._setup_prototype(*args, **kwargs)
    [462](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:462)     self._event_dims = {}
    [463](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:463)     self.locs = PyroModule()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:157](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:157), in AutoGuide._setup_prototype(self, *args, **kwargs)
    [154](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:154) def _setup_prototype(self, *args, **kwargs):
    [155](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:155)     # run the model so we can inspect its structure
    [156](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:156)     model = poutine.block(self.model, self._prototype_hide_fn)
--> [157](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:157)     self.prototype_trace = poutine.block(poutine.trace(model).get_trace)(
    [158](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:158)         *args, **kwargs
    [159](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:159)     )
    [160](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:160)     if self.master is not None:
    [161](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:161)         self.master()._check_prototype(self.prototype_trace)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12), in _context_wrap(context, fn, *args, **kwargs)
     [10](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:10) def _context_wrap(context, fn, *args, **kwargs):
     [11](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:11)     with context:
---> [12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12)         return fn(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:198](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:198), in TraceHandler.get_trace(self, *args, **kwargs)
    [190](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:190) def get_trace(self, *args, **kwargs):
    [191](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:191)     """
    [192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:192)     :returns: data structure
    [193](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:193)     :rtype: pyro.poutine.Trace
   (...)
    [196](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:196)     Calls this poutine and returns its trace instead of the function's return value.
    [197](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:197)     """
--> [198](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:198)     self(*args, **kwargs)
    [199](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:199)     return self.msngr.get_trace()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:180](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:180), in TraceHandler.__call__(self, *args, **kwargs)
    [178](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:178)         exc = exc_type("{}\n{}".format(exc_value, shapes))
    [179](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:179)         exc = exc.with_traceback(traceback)
--> [180](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:180)         raise exc from e
    [181](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:181)     self.msngr.trace.add_node(
    [182](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:182)         "_RETURN", name="_RETURN", type="return", value=ret
    [183](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:183)     )
    [184](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:184) return ret

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174), in TraceHandler.__call__(self, *args, **kwargs)
    [170](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:170) self.msngr.trace.add_node(
    [171](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:171)     "_INPUT", name="_INPUT", type="args", args=args, kwargs=kwargs
    [172](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:172) )
    [173](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:173) try:
--> [174](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174)     ret = self.fn(*args, **kwargs)
    [175](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:175) except (ValueError, RuntimeError) as e:
    [176](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:176)     exc_type, exc_value, traceback = sys.exc_info()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12), in _context_wrap(context, fn, *args, **kwargs)
     [10](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:10) def _context_wrap(context, fn, *args, **kwargs):
     [11](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:11)     with context:
---> [12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12)         return fn(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12), in _context_wrap(context, fn, *args, **kwargs)
     [10](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:10) def _context_wrap(context, fn, *args, **kwargs):
     [11](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:11)     with context:
---> [12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12)         return fn(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448), in PyroModule.__call__(self, *args, **kwargs)
    [446](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:446) def __call__(self, *args, **kwargs):
    [447](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:447)     with self._pyro_context:
--> [448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448)         result = super().__call__(*args, **kwargs)
    [449](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:449)     if (
    [450](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:450)         pyro.settings.get("validate_poutine")
    [451](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:451)         and not self._pyro_context.active
    [452](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:452)         and _is_module_local_param_enabled()
    [453](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:453)     ):
    [454](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:454)         self._check_module_local_param_usage()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194), in Module._call_impl(self, *input, **kwargs)
   [1190](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1190) # If we don't have any hooks, we want to skip the rest of the logic in
   [1191](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1191) # this function, and just call forward.
   [1192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1192) if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   [1193](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1193)         or _global_forward_hooks or _global_forward_pre_hooks):
-> [1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194)     return forward_call(*input, **kwargs)
   [1195](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1195) # Do not call functions when jit is used
   [1196](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1196) full_backward_hooks, non_full_backward_hooks = [], []

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:321](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:321), in LocationModelLinearDependentWMultiExperimentLocationBackgroundNormLevelGeneAlphaPyroModel.forward(self, x_data, idx, batch_index)
    [319](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:319) # cell group loadings
    [320](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:320) shape = self.ones_1_n_groups * b_s_groups_per_location [/](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/) self.n_groups_tensor
--> [321](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:321) rate = self.ones_1_n_groups [/](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/) (n_s_cells_per_location [/](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/) b_s_groups_per_location)
    [322](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:322) with obs_plate as ind:
    [323](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:323)     k = "z_sr_groups_factors"

RuntimeError: The size of tensor a (50) must match the size of tensor b (2163) at non-singleton dimension 1
               Trace Shapes:                
                Param Sites:                
               Sample Sites:                
               m_g_mean dist           | 1 1
                       value           | 1 1
        m_g_alpha_e_inv dist           | 1 1
                       value           | 1 1
                    m_g dist           | 1 9
                       value           | 1 9
 n_s_cells_per_location dist 2163 2163 |    
                       value 2163 2163 |    
b_s_groups_per_location dist 2163    1 |    
                       value 2163    1 |

2d array error output
RuntimeError                              Traceback (most recent call last)
File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174), in TraceHandler.__call__(self, *args, **kwargs)
    [173](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:173) try:
--> [174](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174)     ret = self.fn(*args, **kwargs)
    [175](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:175) except (ValueError, RuntimeError) as e:

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12), in _context_wrap(context, fn, *args, **kwargs)
     [11](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:11) with context:
---> [12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12)     return fn(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12), in _context_wrap(context, fn, *args, **kwargs)
     [11](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:11) with context:
---> [12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12)     return fn(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448), in PyroModule.__call__(self, *args, **kwargs)
    [447](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:447) with self._pyro_context:
--> [448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448)     result = super().__call__(*args, **kwargs)
    [449](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:449) if (
    [450](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:450)     pyro.settings.get("validate_poutine")
    [451](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:451)     and not self._pyro_context.active
    [452](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:452)     and _is_module_local_param_enabled()
    [453](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:453) ):

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194), in Module._call_impl(self, *input, **kwargs)
   [1192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1192) if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   [1193](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1193)         or _global_forward_hooks or _global_forward_pre_hooks):
-> [1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194)     return forward_call(*input, **kwargs)
   [1195](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1195) # Do not call functions when jit is used

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:390](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:390), in LocationModelLinearDependentWMultiExperimentLocationBackgroundNormLevelGeneAlphaPyroModel.forward(self, x_data, idx, batch_index)
    [382](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:382) # =====================Location-specific detection efficiency ======================= #
    [383](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:383) # y_s with hierarchical mean prior
    [384](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:384) detection_mean_y_e = pyro.sample(
    [385](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:385)     "detection_mean_y_e",
    [386](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:386)     dist.Gamma(
    [387](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:387)         self.ones * self.detection_mean_hyp_prior_alpha,
    [388](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:388)         self.ones * self.detection_mean_hyp_prior_beta,
    [389](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:389)     )
--> [390](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:390)     .expand([self.n_batch, 1])
    [391](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:391)     .to_event(2),
    [392](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:392) )
    [393](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:393) detection_hyp_prior_alpha = pyro.deterministic(
    [394](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:394)     "detection_hyp_prior_alpha",
    [395](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:395)     self.ones_n_batch_1 * self.detection_hyp_prior_alpha,
    [396](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:396) )

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:59](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:59), in Gamma.expand(self, batch_shape, _instance)
     [58](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:58) batch_shape = torch.Size(batch_shape)
---> [59](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:59) new.concentration = self.concentration.expand(batch_shape)
     [60](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:60) new.rate = self.rate.expand(batch_shape)

RuntimeError: The expanded size of the tensor (1) must match the existing size (2163) at non-singleton dimension 0.  Target sizes: [1, 1].  Tensor sizes: [2163, 1]

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
Cell In[32], [line 1](vscode-notebook-cell:?execution_count=32&line=1)
----> [1](vscode-notebook-cell:?execution_count=32&line=1) mod.train(max_epochs=3000,
      [2](vscode-notebook-cell:?execution_count=32&line=2)           # train using full data (batch_size=None)
      [3](vscode-notebook-cell:?execution_count=32&line=3)           batch_size=None,
      [4](vscode-notebook-cell:?execution_count=32&line=4)           # use all data points in training because
      [5](vscode-notebook-cell:?execution_count=32&line=5)           # we need to estimate cell abundance at all locations
      [6](vscode-notebook-cell:?execution_count=32&line=6)           train_size=1,
      [7](vscode-notebook-cell:?execution_count=32&line=7)           use_gpu=False,
      [8](vscode-notebook-cell:?execution_count=32&line=8)          )
     [10](vscode-notebook-cell:?execution_count=32&line=10) # plot ELBO loss history during training, removing first 100 epochs from the plot
     [11](vscode-notebook-cell:?execution_count=32&line=11) mod.plot_history(1000)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:209](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:209), in Cell2location.train(self, max_epochs, batch_size, train_size, lr, num_particles, scale_elbo, **kwargs)
    [206](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:206)         scale_elbo = 1.0 [/](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/) (self.summary_stats["n_cells"] * self.summary_stats["n_vars"])
    [207](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:207)     kwargs["plan_kwargs"]["scale_elbo"] = scale_elbo
--> [209](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py:209) super().train(**kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:178](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:178), in PyroSviTrainMixin.train(self, max_epochs, use_gpu, train_size, validation_size, batch_size, early_stopping, lr, training_plan, plan_kwargs, **trainer_kwargs)
    [168](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:168) trainer_kwargs["callbacks"].append(PyroJitGuideWarmup())
    [170](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:170) runner = self._train_runner_cls(
    [171](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:171)     self,
    [172](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:172)     training_plan=training_plan,
   (...)
    [176](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:176)     **trainer_kwargs,
    [177](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:177) )
--> [178](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:178) return runner()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:83](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:83), in TrainRunner.__call__(self)
     [80](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:80) if hasattr(self.data_splitter, "n_val"):
     [81](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:81)     self.training_plan.n_obs_validation = self.data_splitter.n_val
---> [83](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:83) self.trainer.fit(self.training_plan, self.data_splitter)
     [84](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:84) self._update_history()
     [86](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainrunner.py:86) # data splitter only gets these attrs after fit

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:194), in Trainer.fit(self, *args, **kwargs)
    [188](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:188) if isinstance(args[0], PyroTrainingPlan):
    [189](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:189)     warnings.filterwarnings(
    [190](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:190)         action="ignore",
    [191](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:191)         category=UserWarning,
    [192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:192)         message="`LightningModule.configure_optimizers` returned `None`",
    [193](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:193)     )
--> [194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/train/_trainer.py:194) super().fit(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:608](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:608), in Trainer.fit(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
    [606](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:606)     raise TypeError(f"`Trainer.fit()` requires a `LightningModule`, got: {model.__class__.__qualname__}")
    [607](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:607) self.strategy._lightning_module = model
--> [608](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:608) call._call_and_handle_interrupt(
    [609](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:609)     self, self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path
    [610](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:610) )

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:38](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:38), in _call_and_handle_interrupt(trainer, trainer_fn, *args, **kwargs)
     [36](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:36)         return trainer.strategy.launcher.launch(trainer_fn, *args, trainer=trainer, **kwargs)
     [37](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:37)     else:
---> [38](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:38)         return trainer_fn(*args, **kwargs)
     [40](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:40) except _TunerExitException:
     [41](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py:41)     trainer._call_teardown_hook()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:650](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:650), in Trainer._fit_impl(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
    [643](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:643) ckpt_path = ckpt_path or self.resume_from_checkpoint
    [644](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:644) self._ckpt_path = self._checkpoint_connector._set_ckpt_path(
    [645](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:645)     self.state.fn,
    [646](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:646)     ckpt_path,  # type: ignore[arg-type]
    [647](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:647)     model_provided=True,
    [648](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:648)     model_connected=self.lightning_module is not None,
    [649](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:649) )
--> [650](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:650) self._run(model, ckpt_path=self.ckpt_path)
    [652](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:652) assert self.state.stopped
    [653](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:653) self.training = False

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1103](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1103), in Trainer._run(self, model, ckpt_path)
   [1099](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1099) self._checkpoint_connector.restore_training_state()
   [1101](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1101) self._checkpoint_connector.resume_end()
-> [1103](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1103) results = self._run_stage()
   [1105](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1105) log.detail(f"{self.__class__.__name__}: trainer tearing down")
   [1106](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1106) self._teardown()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1182](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1182), in Trainer._run_stage(self)
   [1180](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1180) if self.predicting:
   [1181](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1181)     return self._run_predict()
-> [1182](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1182) self._run_train()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1205](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1205), in Trainer._run_train(self)
   [1202](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1202) self.fit_loop.trainer = self
   [1204](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1204) with torch.autograd.set_detect_anomaly(self._detect_anomaly):
-> [1205](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1205)     self.fit_loop.run()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:194), in Loop.run(self, *args, **kwargs)
    [190](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:190)     return self.on_skip()
    [192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:192) self.reset()
--> [194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:194) self.on_run_start(*args, **kwargs)
    [196](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:196) while not self.done:
    [197](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py:197)     try:

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:217](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:217), in FitLoop.on_run_start(self)
    [214](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:214) self._is_fresh_start_epoch = True
    [215](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:215) self._results.to(device=self.trainer.lightning_module.device)
--> [217](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:217) self.trainer._call_callback_hooks("on_train_start")
    [218](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:218) self.trainer._call_lightning_module_hook("on_train_start")
    [219](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py:219) self.trainer._call_strategy_hook("on_train_start")

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1385](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1385), in Trainer._call_callback_hooks(self, hook_name, *args, **kwargs)
   [1383](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1383)     if callable(fn):
   [1384](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1384)         with self.profiler.profile(f"[Callback]{callback.state_key}.{hook_name}"):
-> [1385](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1385)             fn(self, self.lightning_module, *args, **kwargs)
   [1387](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1387) if pl_module:
   [1388](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1388)     # restore current_fx when nested context
   [1389](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py:1389)     pl_module._current_fx_name = prev_fx_name

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:45](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:45), in PyroJitGuideWarmup.on_train_start(self, trainer, pl_module)
     [43](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:43) tens = {k: t.to(pl_module.device) for k, t in tensors.items()}
     [44](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:44) args, kwargs = pl_module.module._get_fn_args_from_batch(tens)
---> [45](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:45) pyro_guide(*args, **kwargs)
     [46](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/scvi/model/base/_pyromixin.py:46) break

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448), in PyroModule.__call__(self, *args, **kwargs)
    [446](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:446) def __call__(self, *args, **kwargs):
    [447](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:447)     with self._pyro_context:
--> [448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448)         result = super().__call__(*args, **kwargs)
    [449](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:449)     if (
    [450](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:450)         pyro.settings.get("validate_poutine")
    [451](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:451)         and not self._pyro_context.active
    [452](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:452)         and _is_module_local_param_enabled()
    [453](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:453)     ):
    [454](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:454)         self._check_module_local_param_usage()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194), in Module._call_impl(self, *input, **kwargs)
   [1190](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1190) # If we don't have any hooks, we want to skip the rest of the logic in
   [1191](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1191) # this function, and just call forward.
   [1192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1192) if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   [1193](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1193)         or _global_forward_hooks or _global_forward_pre_hooks):
-> [1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194)     return forward_call(*input, **kwargs)
   [1195](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1195) # Do not call functions when jit is used
   [1196](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1196) full_backward_hooks, non_full_backward_hooks = [], []

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:510](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:510), in AutoNormal.forward(self, *args, **kwargs)
    [508](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:508) # if we've never run the model before, do so now so we can inspect the model structure
    [509](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:509) if self.prototype_trace is None:
--> [510](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:510)     self._setup_prototype(*args, **kwargs)
    [512](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:512) plates = self._create_plates(*args, **kwargs)
    [513](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:513) result = {}

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:460](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:460), in AutoNormal._setup_prototype(self, *args, **kwargs)
    [459](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:459) def _setup_prototype(self, *args, **kwargs):
--> [460](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:460)     super()._setup_prototype(*args, **kwargs)
    [462](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:462)     self._event_dims = {}
    [463](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:463)     self.locs = PyroModule()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:157](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:157), in AutoGuide._setup_prototype(self, *args, **kwargs)
    [154](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:154) def _setup_prototype(self, *args, **kwargs):
    [155](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:155)     # run the model so we can inspect its structure
    [156](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:156)     model = poutine.block(self.model, self._prototype_hide_fn)
--> [157](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:157)     self.prototype_trace = poutine.block(poutine.trace(model).get_trace)(
    [158](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:158)         *args, **kwargs
    [159](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:159)     )
    [160](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:160)     if self.master is not None:
    [161](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/infer/autoguide/guides.py:161)         self.master()._check_prototype(self.prototype_trace)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12), in _context_wrap(context, fn, *args, **kwargs)
     [10](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:10) def _context_wrap(context, fn, *args, **kwargs):
     [11](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:11)     with context:
---> [12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12)         return fn(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:198](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:198), in TraceHandler.get_trace(self, *args, **kwargs)
    [190](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:190) def get_trace(self, *args, **kwargs):
    [191](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:191)     """
    [192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:192)     :returns: data structure
    [193](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:193)     :rtype: pyro.poutine.Trace
   (...)
    [196](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:196)     Calls this poutine and returns its trace instead of the function's return value.
    [197](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:197)     """
--> [198](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:198)     self(*args, **kwargs)
    [199](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:199)     return self.msngr.get_trace()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:180](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:180), in TraceHandler.__call__(self, *args, **kwargs)
    [178](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:178)         exc = exc_type("{}\n{}".format(exc_value, shapes))
    [179](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:179)         exc = exc.with_traceback(traceback)
--> [180](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:180)         raise exc from e
    [181](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:181)     self.msngr.trace.add_node(
    [182](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:182)         "_RETURN", name="_RETURN", type="return", value=ret
    [183](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:183)     )
    [184](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:184) return ret

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174), in TraceHandler.__call__(self, *args, **kwargs)
    [170](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:170) self.msngr.trace.add_node(
    [171](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:171)     "_INPUT", name="_INPUT", type="args", args=args, kwargs=kwargs
    [172](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:172) )
    [173](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:173) try:
--> [174](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:174)     ret = self.fn(*args, **kwargs)
    [175](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:175) except (ValueError, RuntimeError) as e:
    [176](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/trace_messenger.py:176)     exc_type, exc_value, traceback = sys.exc_info()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12), in _context_wrap(context, fn, *args, **kwargs)
     [10](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:10) def _context_wrap(context, fn, *args, **kwargs):
     [11](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:11)     with context:
---> [12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12)         return fn(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12), in _context_wrap(context, fn, *args, **kwargs)
     [10](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:10) def _context_wrap(context, fn, *args, **kwargs):
     [11](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:11)     with context:
---> [12](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/poutine/messenger.py:12)         return fn(*args, **kwargs)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448), in PyroModule.__call__(self, *args, **kwargs)
    [446](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:446) def __call__(self, *args, **kwargs):
    [447](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:447)     with self._pyro_context:
--> [448](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:448)         result = super().__call__(*args, **kwargs)
    [449](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:449)     if (
    [450](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:450)         pyro.settings.get("validate_poutine")
    [451](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:451)         and not self._pyro_context.active
    [452](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:452)         and _is_module_local_param_enabled()
    [453](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:453)     ):
    [454](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/pyro/nn/module.py:454)         self._check_module_local_param_usage()

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194), in Module._call_impl(self, *input, **kwargs)
   [1190](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1190) # If we don't have any hooks, we want to skip the rest of the logic in
   [1191](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1191) # this function, and just call forward.
   [1192](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1192) if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   [1193](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1193)         or _global_forward_hooks or _global_forward_pre_hooks):
-> [1194](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1194)     return forward_call(*input, **kwargs)
   [1195](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1195) # Do not call functions when jit is used
   [1196](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/nn/modules/module.py:1196) full_backward_hooks, non_full_backward_hooks = [], []

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:390](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:390), in LocationModelLinearDependentWMultiExperimentLocationBackgroundNormLevelGeneAlphaPyroModel.forward(self, x_data, idx, batch_index)
    [373](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:373)         pyro.sample(
    [374](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:374)             k + "_initial",
    [375](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:375)             dist.Gamma(
   (...)
    [379](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:379)             obs=w_sf,
    [380](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:380)         )  # (self.n_obs, self.n_factors)
    [382](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:382) # =====================Location-specific detection efficiency ======================= #
    [383](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:383) # y_s with hierarchical mean prior
    [384](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:384) detection_mean_y_e = pyro.sample(
    [385](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:385)     "detection_mean_y_e",
    [386](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:386)     dist.Gamma(
    [387](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:387)         self.ones * self.detection_mean_hyp_prior_alpha,
    [388](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:388)         self.ones * self.detection_mean_hyp_prior_beta,
    [389](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:389)     )
--> [390](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:390)     .expand([self.n_batch, 1])
    [391](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:391)     .to_event(2),
    [392](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:392) )
    [393](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:393) detection_hyp_prior_alpha = pyro.deterministic(
    [394](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:394)     "detection_hyp_prior_alpha",
    [395](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:395)     self.ones_n_batch_1 * self.detection_hyp_prior_alpha,
    [396](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:396) )
    [398](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/cell2location/models/_cell2location_module.py:398) beta = (obs2sample @ detection_hyp_prior_alpha) [/](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/) (obs2sample @ detection_mean_y_e)

File [~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:59](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:59), in Gamma.expand(self, batch_shape, _instance)
     [57](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:57) new = self._get_checked_instance(Gamma, _instance)
     [58](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:58) batch_shape = torch.Size(batch_shape)
---> [59](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:59) new.concentration = self.concentration.expand(batch_shape)
     [60](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:60) new.rate = self.rate.expand(batch_shape)
     [61](https://vscode-remote+ssh-002dremote-002bnorgay-002eucsf-002eedu.vscode-resource.vscode-cdn.net/home/ssobti/projects/farnaz_spatial/notebooks/monkey_data/cell2location_multi_ref_combined/~/miniconda3/envs/cell2loc_env/lib/python3.10/site-packages/torch/distributions/gamma.py:61) super(Gamma, new).__init__(batch_shape, validate_args=False)

RuntimeError: The expanded size of the tensor (1) must match the existing size (2163) at non-singleton dimension 0.  Target sizes: [1, 1].  Tensor sizes: [2163, 1]
               Trace Shapes:                
                Param Sites:                
               Sample Sites:                
               m_g_mean dist         |  1  1
                       value         |  1  1
        m_g_alpha_e_inv dist         |  1  1
                       value         |  1  1
                    m_g dist         |  1  9
                       value         |  1  9
 n_s_cells_per_location dist 2163  1 |      
                       value 2163  1 |      
b_s_groups_per_location dist 2163  1 |      
                       value 2163  1 |      
    z_sr_groups_factors dist 2163 50 |      
                       value 2163 50 |      
 k_r_factors_per_groups dist         | 50  1
                       value         | 50  1
        x_fr_group2fact dist         | 50 20
                       value         | 50 20
                   w_sf dist 2163 20 |      
                       value 2163 20 |

alpha 0.5
image

alpha 5
image

alpha 20
image

@huiyijiangling
Copy link

Whether the problem have be sloved? I am interested in using the N_cells_per_location function by inputing nuclei counts.

@vitkl
Copy link
Contributor

vitkl commented Jul 25, 2024

Hi @huiyijiangling @ssobt

We are working on incorporating this information at the moment. It is not as simple as changing the above line but requires substantial changes to the model to effectively use segmentation-derived N_cells_per_location. While this will become possible in a month or so - you need to keep in mind that segmentation is not possible for all datasets and it is mostly reliable for FFPE protocols.

@vitkl
Copy link
Contributor

vitkl commented Jul 25, 2024

Also, when you provide segmentation information detection_alpha has to be large, eg 200.

Segmentation information and large detection_alpha=200 would likely become the new recommended setting.

@benoitsam
Copy link

Hi @vitkl

First of all, thank you for your work !

I'm also interested so If you have any news about your previous comments (the possibility to input the number of cells per-spot instead of a sample-wise value), let us know 😄

Regards,
Benoit

@benoitsam
Copy link

Hi @vitkl !

Do you have any news ? 😄

@vitkl
Copy link
Contributor

vitkl commented Oct 18, 2024

Hi @benoitsam

You can try using this experimental branch #337 (comment). I am planning to finalise this branch and its dependencies (scvi-tools) by December-February.

@benoitsam
Copy link

Hi @vitkl

Thanks for your reply ! I'll try to follow your instructions to install and use this new feature asap and I'll get back here with the results 😄

@benoitsam
Copy link

Hi @vitkl

Quick comments for the #337 :

Installation

There was an error with the scvi-tools that you forked.
They removed the optional scvi.criticism package so a dirty fix was to do :

git clone https://github.com/vitkl/scvi-tools.git --single-branch --branch pyro_fixes

pyproject.toml : Removed "criticism" line 90

pip install ../scvi-tools

And then for cell2location with your ongoing branch :
pip install "cell2location[tutorials] @ git+https://github.com/BayraktarLab/cell2location.git@hires_sliding_window"

It works if I do import cell2location in python interpreter.

Usage

Could you elaborate on your comment about your N_cells_per_location comment ?

# ideally this is not count of cells
# but % of spot occupied by cells * 0.9999 quantile of N cells across the data

I'm not sure to understand what I'm supposed to use as input because I've got only a count of cells by spot 🤔

Regards,
Benoit

@vitkl
Copy link
Contributor

vitkl commented Oct 29, 2024

Thanks for suggesting the fix. Good to know.

The idea is that cell abundance is proportional to the number of cells and % of the spot occupied by cells - so combining the two measures gives a better result.

You can use a count of cells by spot too. You need to delete spots with 0 cells.

@benoitsam
Copy link

benoitsam commented Nov 7, 2024

Hi @vitkl

Just to let you know, I managed to use this version on my laptop on a toy dataset.
However, I'm currently trying to use it on a real sample (nextflow pipeline on GPU cluster with SLURM) and I encounter some memory issues.

Run info:

sample=3000 spots
use_gpu=True
Nb intersecting genes : 14358
RAM: between 60 to 120 Go -> OOM

For cell2location parameters :

max_epochs=30000
posterior_sampling=1000

The "out of memory" issue appears every time after the training completed (even with 30000 iterations, I've got the Trainer.fit stopped: max_epochs=30000 reached. ) but during the start of the export_posterior method.

The job ends correctly if I use max_epochs and posterior_sampling with low value like 10.

I wondered if you suspect that your modifications may have impacted the resources required to run cell2location.
(Because I managed to use the "classical" version on same cluster with same parameters)

Regards,
Benoit

@vitkl
Copy link
Contributor

vitkl commented Nov 7, 2024

Hi @benoitsam

It looks like the issue is with posterior sampling rather than training, and you run out of RAM, not GPU memory, right?

The resource change may be due to the new version rather than to using these settings. Do you mean that you are using old parameters with new code?

In general, I would recommend computing quantiles directly like this:

    # In this section, we export the estimated cell abundance (summary of the posterior distribution).
    adata_vis = mod.export_posterior(
        adata_vis, sample_kwargs={
            'batch_size': int(np.ceil(adata_vis.n_obs / 8)),  # this has to be done in batches due to a bug in the code new version
            'accelerator': 'gpu',
            'return_observed': False,
        },
        add_to_obsm=['q05', 'q95', 'q50'],
        use_quantiles=True,
    )

@benoitsam
Copy link

benoitsam commented Nov 7, 2024

It looks like the issue is with posterior sampling rather than training, and you run out of RAM, not GPU memory, right?

Yes it seems to be an Out of Memory from RAM. I had no warning or error log about GPU memory or CUDA issues.

The resource change may be due to the new version rather than to using these settings. Do you mean that you are using old parameters with new code?

I meant that I used the same "configuration" when I used cell2location (v0.1.4) with N_cells_per_location for the whole sample. "Same configuration" as same cluster, nextflow, SLURM, epoch for training etc...
I tried to use the v0.1.5 by adapting the code and following your comments about the various changes.

In general, I would recommend computing quantiles directly like this:

I tried your suggestion. It works locally with the toy dataset (1700 spots, 10 epoch for the training).
But with the real sample I've got :

Traceback (most recent call last):
    File "/sps/lbmc/bsamson/vap/subworkflows/deconvolution/cell2location/fit_model_prior_by_spot.py", line 210, in <module>
      main()
    File "/sps/lbmc/bsamson/vap/subworkflows/deconvolution/cell2location/fit_model_prior_by_spot.py", line 185, in main
      adata_vis = mod.export_posterior(
    File "/pbs/throng/lbmc/bsamson/software/miniconda3/envs/cell2loc_prior_by_spot_env/lib/python3.10/site-packages/cell2location/models/_cell2location_model.py", line 520, in export_posterior
      self.samples[f"post_sample_{i}"] = self.posterior_quantile(q=q, **sample_kwargs)
    File "/pbs/throng/lbmc/bsamson/software/miniconda3/envs/cell2loc_prior_by_spot_env/lib/python3.10/site-packages/cell2location/models/base/_pyro_mixin.py", line 570, in posterior_quantile
      return self._posterior_quantile_minibatch(exclude_vars=exclude_vars, batch_size=batch_size, **kwargs)
    File "/pbs/throng/lbmc/bsamson/software/miniconda3/envs/cell2loc_prior_by_spot_env/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
      return func(*args, **kwargs)
    File "/pbs/throng/lbmc/bsamson/software/miniconda3/envs/cell2loc_prior_by_spot_env/lib/python3.10/site-packages/cell2location/models/base/_pyro_mixin.py", line 444, in _posterior_quantile_minibatch
      valid_sites = self._get_valid_sites(args, kwargs, return_observed=return_observed)
  AttributeError: 'Cell2location' object has no attribute '_get_valid_sites'

EDIT:
It seems the error comes from me 😄
This method exists in your pyro_fixes branch of scvi-tools and is called locally mon my laptop.
It must be an installation mixup of scvi-tools on my cluster 🤔

@benoitsam
Copy link

At last, it worked on my cluster for real samples 👍

@benoitsam
Copy link

benoitsam commented Nov 25, 2024

Hi @vitkl !

I have some questions for you 😄

  1. About the hires_sliding_window branch. Does it only impact the spatial mapping part ?
    If I already estimated cell-types signatures from a single-reference with cell2location (main branch), I can use the same "model" for the mapping part with this hires_sliding_window branch (that work the number of cells / spot as a prior instead of a sample-wise one) ?
  2. By curiosity, does the following Elbow plot for the signature stimation part looks good to you or do I need to increase the number of epochs to train on my single-cell reference ?
    Int6xGoPit_LowG_BS_elbow_loss_history
    It seems the values varies often, but in a very small range so I was wondering 🤔
  3. Is it possible (or recommended) to execute spatial mapping on one merged/integrated sample that combine several ? For now I've used it on each sample separately but I wondered, If I wanted to do a run on merged/integrated ones I could get tens of thousands of spots. Would it be an issue ? Are you aware of any number of spots limitations ? 🤔

Regards,
Benoit

@benoitsam
Copy link

Hi @vitkl !

Do you have any news ? :)

@vitkl
Copy link
Contributor

vitkl commented Dec 10, 2024

Hi @benoitsam

  1. Yes the new branch only affects the spatial mapping model, you can use the same reference.

  2. Is the ELBO plot for the reference model? If yes, it looks good and if anything you can stop training earlier (eg 600 epoch). You can test using both and the results are likely going to be similar.

  3. In general we recommend using as many samples as possible - see supplementary methods section for rationale

Screenshot 2024-12-10 at 10 19 28 Screenshot 2024-12-10 at 10 19 57

https://static-content.springer.com/esm/art%3A10.1038%2Fs41587-021-01139-4/MediaObjects/41587_2021_1139_MOESM1_ESM.pdf

The limit on the number of spots is GPU memory. See this issue for suggestions about large data #356 - in particular, splitting the data into training batches stratified by Visium batch aka capture area.

@vitkl vitkl added enhancement New feature or request discussion for next release FAQ and removed bug Something isn't working labels Dec 10, 2024
@benoitsam
Copy link

Hi @vitkl ! (and happy new year!)

Thank you for your previous answer, I'll consider the merge of samples.

I have some questions for you about my output of cell2location for the hires_sliding_window branch.

For some context :

  • I've got 16 visium samples on cancer pituitary tissues and a "in-house" single-cell reference for the same tissue (23k cells, 14k genes after cell2location filtering, 12 cell types)
  • For each sample, I've got the number of cells / spots from a custom segmentation tool
  • I've used the released version of cell2location with N_cells_per_location=30 and N_cells_per_location=mean(nb cells / spot) from the segmentation and also the hires_sliding_window one to compare (by using your previous instructions)
  • One of my issues is that if I compare the abundance / spot of the released version of cell2location and the hires_sliding_window one , I can see some huge differences for a cell type that is not expected to be present in that amount (BCells).
    For example, the figure below (one dot is the abundance for one spot, faceted by cell type, x=cell2location released, y=cell2location_hires_sliding_window :
    image
  • This behavior happens for all my samples.
  • By curiosity, I removed the BCells from my reference and the "issue" transposed to the TCells. If I remove the TCells, it will affect the MastCells, and If I remove the MastCells it will be the neutrophils that "appear" as strongly present (the "removal" part was only done for one visium sample to speed-up those tests). Besides, it looks like even if the "overestimated" abundance jumps on another cell-type, the spatial location of affected spots are the same.
  • I tried the same approach on public 10x visium datasets for breast and prostate samples (with public curated references) and I've got the same kind of "overestimation" for BCells and TCells (again some immune cells) 🤔
  • So I wondered if you encountered that kind of results 😅
    -I don't know if the issue comes from me and I'm still investigating if there was an issue from my part.
  • I also cannot pretend to understand the math at work but I wondered if that would be possible that this new version, with a prior coming from segmentation / spot, imposes a kind of "hard constraint" on the resulted abundance that could "force" some abundance in under-represented cell types. 🤔

Well, sorry for the long text and thank you in advance if you have read all that !
If you need more info, I'll be glad to provide it :)

Benoit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants