code: def _square_observable(obs):
      """Returns the square of an observable."""
  
      if isinstance(obs, qml.operation.Tensor):
          # Observable is a tensor, we must consider its
          # component observables independently. Note that
          # we assume all component observables are on distinct wires.
  
          components_squared = []
  
          for comp in obs.obs:
              try:
                  components_squared.append(
                      NONINVOLUTORY_OBS[comp.name](comp)
                  )
              except KeyError:
                  # component is involutory
                  pass
  
          return qml.operation.Tensor(*components_squared)
  
      return NONINVOLUTORY_OBS[obs.name](obs)
  
imports: from typing import Sequence, Callable
  from functools import partial
  import numpy
  import pennylane
  from pennylane.measurements import VarianceMP
  from pennylane import transform
  from pennylane.transforms.tape_expand import expand_invalid_trainable
  from pennylane.gradients.gradient_transform import _contract_qjac_with_cjac
  from .finite_difference import finite_diff
  from .general_shift_rules import _iterate_shift_rule, frequencies_to_period, generate_shifted_tapes, process_shifts
  from .gradient_transform import _all_zero_grad, assert_no_state_returns, assert_no_tape_batching, assert_multimeasure_not_broadcasted, choose_trainable_params, find_and_validate_gradient_methods, _no_trainable_grad, reorder_grads
label_desc: Use image node_id 1 for calling a global function with example usage: _square_observable(obs) and returns: NONINVOLUTORY_OBS, qml