docstr: An utility to convert a `Mirrored`, `Tensor` or `IndexedSlices` to a list.
  
  The reason it exists is to provide a uniformed view of returned value of
  "reduce" calls, especially across tf.function boundaries. Returning
  `Mirrored` from a tf.function will only evaluate the primary value, which
  makes collective ops of non-primary device being pruned, and will eventually
  cause hanging.
  
  Args:
    value: the value to convert, can be one of `Mirrored`, `Tensor` and
      `IndexedSlices`.
  
  Returns:
    A list of `Tensor` or `IndexedSlices`.
docstr_tok: ["An","utility","to","convert","a","`","Mirrored","`",",","`","Tensor","`","or","`","IndexedSlices","`","to","a","list",".","The","reason","it","exists","is","to","provide","a","uniformed","view","of","returned","value","of","''","reduce","''","calls",",","especially","across","tf.function","boundaries",".","Returning","`","Mirrored","`","from","a","tf.function","will","only","evaluate","the","primary","value",",","which","makes","collective","ops","of","non-primary","device","being","pruned",",","and","will","eventually","cause","hanging",".","Args",":","value",":","the","value","to","convert",",","can","be","one","of","`","Mirrored","`",",","`","Tensor","`","and","`","IndexedSlices","`",".","Returns",":","A","list","of","`","Tensor","`","or","`","IndexedSlices","`","."]
code: def as_list(self, value):
      """An utility to convert a `Mirrored`, `Tensor` or `IndexedSlices` to a list.
  
      The reason it exists is to provide a uniformed view of returned value of
      "reduce" calls, especially across tf.function boundaries. Returning
      `Mirrored` from a tf.function will only evaluate the primary value, which
      makes collective ops of non-primary device being pruned, and will eventually
      cause hanging.
  
      Args:
        value: the value to convert, can be one of `Mirrored`, `Tensor` and
          `IndexedSlices`.
  
      Returns:
        A list of `Tensor` or `IndexedSlices`.
      """
      if isinstance(value, tensor_lib.Tensor):
          return [value]
      elif isinstance(value, IndexedSlices):
          return [value]
      elif isinstance(value, value_lib.Mirrored):
          return value.values
      else:
          raise ValueError(
              "unwrap: unsupported input type: %s" % type(value)
          )
  
imports: import collections
  import os
  import threading
  import time
  from absl.testing import parameterized
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.core.protobuf import tensorflow_server_pb2
  from tensorflow.python.distribute import cluster_resolver
  from tensorflow.python.distribute import collective_util
  from tensorflow.python.distribute import combinations
  from tensorflow.python.distribute import cross_device_ops
  from tensorflow.python.distribute import cross_device_utils
  from tensorflow.python.distribute import device_util
  from tensorflow.python.distribute import multi_process_runner
  from tensorflow.python.distribute import multi_worker_test_base
  from tensorflow.python.distribute import reduce_util
  from tensorflow.python.distribute import test_util
  from tensorflow.python.distribute import values
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.eager import test
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import collective_ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import math_ops
  from tensorflow.python.util import nest
label_desc: Use image node_id 3 for calling the CollectiveOpsTest obj's underlying member method code with example usage: obj.as_list(value) and returns: list, list, value