class_docstr: Class that handles conversion of pytorch models represented in TorchScript
  format to the MIL format.
  
  Models passed to the @TorchConverter go from:
  TorchScript -> Expanded/Optimized Torch IR -> Internal Graph -> CoreML SSA
  The internal graph representation was added to make testing easier.
  
  Arguments:
      torchscript: torch.jit.ScriptModule object representing the model to convert.
      inputs: Input values and optional names. See kwarg in load.py for full description.
      outputs: Names of the graph's outputs. See kwarg in load.py for full description.
      cut_at_symbols: A list of internal symbol name strings. Graph conversion will
          terminate once these symbols have been generated. For debugging use
          only. See kwarg in load.py.
class_docstr_tok: ["Class","that","handles","conversion","of","pytorch","models","represented","in","TorchScript","format","to","the","MIL","format",".","Models","passed","to","the","@","TorchConverter","go","from",":","TorchScript","-",">","Expanded\/Optimized","Torch","IR","-",">","Internal","Graph","-",">","CoreML","SSA","The","internal","graph","representation","was","added","to","make","testing","easier",".","Arguments",":","torchscript",":","torch.jit.ScriptModule","object","representing","the","model","to","convert",".","inputs",":","Input","values","and","optional","names",".","See","kwarg","in","load.py","for","full","description",".","outputs",":","Names","of","the","graph","'s","outputs",".","See","kwarg","in","load.py","for","full","description",".","cut_at_symbols",":","A","list","of","internal","symbol","name","strings",".","Graph","conversion","will","terminate","once","these","symbols","have","been","generated",".","For","debugging","use","only",".","See","kwarg","in","load.py","."]
docstr: Given a torch.jit.ScriptModule, convert it to a optimized
  torch._C.Graph and dict of model parameter's names to tensors.
docstr_tok: ["Given","a","torch.jit.ScriptModule",",","convert","it","to","a","optimized","torch._C.Graph","and","dict","of","model","parameter","'s","names","to","tensors","."]
code: def _expand_and_optimize_ir(torchscript):
      """Given a torch.jit.ScriptModule, convert it to a optimized
      torch._C.Graph and dict of model parameter's names to tensors.
      """
  
      # Recursively replaces all attribute accesses with the sub-graphs of
      # those modules. The resulting graph will be self-contained and will
      # not reference into other modules. Params will contain the "trainable"
      # inputs to the graph.
      graph, params = _torch._C._jit_pass_lower_graph(
          torchscript.forward.graph, torchscript._c
      )
  
      # From PyTorch code: Inline function and method calls.
      _torch._C._jit_pass_inline(graph)
      # From PyTorch code: This inlines the forked section in the fork()
      # callsite and replaces uses of the result of wait() calls with the
      # values produced from the (now-inlined) forked section.
      _torch._C._jit_pass_inline_fork_wait(graph)
      # Starting from the return node, marks all nodes that feed into the
      # output, as well as nodes with side effects. Any nodes not marked are
      # eliminated.
      _torch._C._jit_pass_dce(graph)
      # From PyTorch code: checks well-formedness and invariants of graph.
      _torch._C._jit_pass_lint(graph)
      # From PyTorch code: remove all in-place ops and replace them with
      # out-of-place equivalents.
      # e.g.
      #   %foo = aten::add_(%foo, %n)
      # becomes
      #   %foo.2 = aten::add(%foo, %n)
      _torch._C._jit_pass_remove_inplace_ops(graph)
      _torch._C._jit_pass_dce(graph)
      _torch._C._jit_pass_lint(graph)
      # Replaces a couple specific ops patterns (add, sub, mul, div, chunk).
      _torch._C._jit_pass_canonicalize_ops(graph)
      _torch._C._jit_pass_lint(graph)
      # From PyTorch code: This pass catches all of the small, easy to catch
      # peephole optimizations you might be interested in doing.
      #     Eliminate no-op 'expand' nodes
      #     Simplify x.t().t() to x
      _torch._C._jit_pass_peephole(graph, addmm_fusion_enabled=False)
      _torch._C._jit_pass_lint(graph)
      # From PyTorch docs: Renumber the graph so that all structurally
      # equivalent graphs have same numbers.
      graph = _torch._C._jit_pass_canonicalize(graph)
      _torch._C._jit_pass_lint(graph)
      _torch._C._jit_pass_constant_propagation(graph)
      # NOTE: Don't need another DCE, it's included in constant propagation.
      _torch._C._jit_pass_lint(graph)
  
      input_and_param_names = [
          val.debugName() for val in graph.inputs()
      ]
      param_names = input_and_param_names[
          len(input_and_param_names) - len(params) :
      ]
      params_dict = dict(zip(param_names, params))
  
      return graph, params_dict
  
imports: from __future__ import print_function
  from six import string_types
  import logging
  import torch
  from coremltools.converters.mil.input_types import InputType, ImageType
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Placeholder, Function, Program, get_new_symbol
  from coremltools.converters.mil.mil import Var
  from .internal_graph import *
  from .ops import *
  from .torch_op_registry import _TORCH_OPS_REGISTRY
  from .torchir_passes import *
label_desc: Use image node_id 6 for calling the TorchConverter obj's underlying member method code with example usage: obj._expand_and_optimize_ir(torchscript) and returns: graph,  params_dict