class_docstr: Profiler based on `nnMeter <https://github.com/microsoft/nn-Meter>`__,
  which is a tool to estimate the latency of neural networks without real device.
  
  The profiler breaks the whole model into submodules and profiles each of them,
  introducing branches when some part of the model contains mutables.
  The latency of a module is the sum of the latency of its submodules.
  
  :class:`NnMeterProfiler` does not respect :func:`~nni.nas.profiler.pytorch.utils.is_leaf_module`
  when it profiles the latency of the model space.
  To control the granularity, inherit this class and override :meth:`is_leaf_module`.
  
  Parameters
  ----------
  model_space
      The model space to profile.
  args
      Dummy inputs to the model to count flops.
      Similar to `torch.onnx.export <https://pytorch.org/docs/stable/onnx.html#torch.onnx.export>`__,
      the input can be a tensor or a tuple of tensors, or a tuple of arguments ends with a dictionary of keyword arguments.
  predictor
      The latency predictor to use. Can be a string (alias of nnMeterPredictor) or a :class:`nnMeterPredictor`.
  custom_leaf_types
      A tuple of types of modules that should be considered as leaf modules.
  simplify_shapes
      Experimental feature. If True, the shapes of the inputs and outputs of each module
      will be mathematically simplified with the underlying sympy library.
class_docstr_tok: ["Profiler","based","on","`","nnMeter","<","https",":","\/\/github.com\/microsoft\/nn-Meter",">","`","__",",","which","is","a","tool","to","estimate","the","latency","of","neural","networks","without","real","device",".","The","profiler","breaks","the","whole","model","into","submodules","and","profiles","each","of","them",",","introducing","branches","when","some","part","of","the","model","contains","mutables",".","The","latency","of","a","module","is","the","sum","of","the","latency","of","its","submodules",".",":","class",":","`","NnMeterProfiler","`","does","not","respect",":","func",":","`","~nni.nas.profiler.pytorch.utils.is_leaf_module","`","when","it","profiles","the","latency","of","the","model","space",".","To","control","the","granularity",",","inherit","this","class","and","override",":","meth",":","`","is_leaf_module","`",".","Parameters","--","--","--","--","--","model_space","The","model","space","to","profile",".","args","Dummy","inputs","to","the","model","to","count","flops",".","Similar","to","`","torch.onnx.export","<","https",":","\/\/pytorch.org\/docs\/stable\/onnx.html","#","torch.onnx.export",">","`","__",",","the","input","can","be","a","tensor","or","a","tuple","of","tensors",",","or","a","tuple","of","arguments","ends","with","a","dictionary","of","keyword","arguments",".","predictor","The","latency","predictor","to","use",".","Can","be","a","string","(","alias","of","nnMeterPredictor",")","or","a",":","class",":","`","nnMeterPredictor","`",".","custom_leaf_types","A","tuple","of","types","of","modules","that","should","be","considered","as","leaf","modules",".","simplify_shapes","Experimental","feature",".","If","True",",","the","shapes","of","the","inputs","and","outputs","of","each","module","will","be","mathematically","simplified","with","the","underlying","sympy","library","."]
docstr: Estimate the latency of a Repeat.
  
  Profile each block and merge possibilities at different depths into a switch-case expression.
docstr_tok: ["Estimate","the","latency","of","a","Repeat",".","Profile","each","block","and","merge","possibilities","at","different","depths","into","a","switch-case","expression","."]
code: def estimate_repeat_latency(
      self, name: str, module: Repeat, shapes: dict[str, Any]
  ) -> MutableExpression[float] | float:
      """Estimate the latency of a Repeat.
  
      Profile each block and merge possibilities at different depths into a switch-case expression.
      """
      if isinstance(module.depth_choice, int):
          # Nothing mutable.
          return sum(
              self.estimate_latency(concat_name(name, n), child, shapes)
              for n, child in module.named_children()
          )
  
      else:
          sub_results: list[MutableExpression] = []
          for depth, sub in enumerate(module.blocks, start=1):
              sub_results.append(
                  (module.depth_choice >= depth)
                  * self.estimate_latency(
                      concat_name(name, f"blocks.{depth - 1}"),
                      sub,
                      shapes,
                  )
              )
          return sum(sub_results)
  
imports: from __future__ import annotations
  import functools
  import logging
  import tempfile
  from typing import Any, Iterable
  import torch
  from torch import nn
  from nn_meter import load_latency_predictor, nnMeterPredictor
  from nni.mutable import Mutable, MutableList, LabeledMutable, Sample, MutableExpression
  from nni.nas.nn.pytorch import ModelSpace, MutableModule, LayerChoice, Repeat
  from nni.nas.profiler import ExpressionProfiler
  from .utils import MutableShape, ShapeTensor, standardize_arguments, submodule_input_output_shapes, is_leaf_module, concat_name
label_desc: Use image node_id 5 for calling the NnMeterProfiler obj's underlying member method code with example usage: obj.estimate_repeat_latency(name, module, shapes) and returns: sum, sum