docstr: Sanitize the vars and op names inside the block to adhere to the format [a-zA-Z_][a-zA-Z0-9_]*
docstr_tok: ["Sanitize","the","vars","and","op","names","inside","the","block","to","adhere","to","the","format","[","a-zA-Z_","]","[","a-zA-Z0-9_","]","*"]
code: def sanitize_block(
      block,
      sanitizer_vars,
      sanitizer_ops,
      main_input_types=None,
      sanitize_model_inputs_outputs_only=False,
  ):
      """
      Sanitize the vars and op names inside the block to adhere to the format [a-zA-Z_][a-zA-Z0-9_]*
      """
  
      if sanitize_model_inputs_outputs_only:
          NameSanitizer._sanitize_block_input_vars(
              block,
              sanitizer_vars,
              main_input_types,
              sanitize_main_input_only=True,
          )
          NameSanitizer._sanitize_main_outputs_only(
              block, sanitizer_vars
          )
      else:
          NameSanitizer._sanitize_block_input_vars(
              block, sanitizer_vars, main_input_types
          )
          NameSanitizer._sanitize_output_vars_and_nested_blocks(
              block, sanitizer_vars, sanitizer_ops
          )
          NameSanitizer._sanitize_op_names(block, sanitizer_ops)
  
imports: import re
  import warnings
  from collections import OrderedDict
  from coremltools import _logger
  from coremltools.converters.mil.input_types import EnumeratedShapes, ImageType, Shape
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Function, types
  from coremltools.converters.mil.mil.passes.graph_pass import AbstractGraphPass
  from coremltools.converters.mil.mil.passes.pass_registry import register_pass
label_desc: Use image node_id 4 for calling the NameSanitizer obj's underlying member method code with example usage: obj.sanitize_block(block, sanitizer_vars, sanitizer_ops, main_input_types, sanitize_model_inputs_outputs_only) without return types