parameters: (self, name=None)
return_statement: return values.regroup(self._input_workers.device_map, replicas)
docstring: Returns the next input from the iterator for all replicas.
docstring_summary: Returns the next input from the iterator for all replicas.
docstring_tokens: Returns the next input from the iterator for all replicas .
function: def get_next(self, name=None):
      """Returns the next input from the iterator for all replicas."""
      if not self._enable_get_next_as_optional:
        replicas = []
        for i, worker in enumerate(self._input_workers.worker_devices):
          if name is not None:
            d = tf_device.DeviceSpec.from_string(worker)
            new_name = "%s_%s_%d" % (name, d.job, d.task)
          else:
            new_name = None
          with ops.device(worker):
            # Make `replicas` a flat list of values across all replicas.
            replicas.extend(
                self._iterators[i].get_next_as_list_deprecated(new_name))
        return values.regroup(self._input_workers.device_map, replicas)
  
      out_of_range_replicas = []
      def out_of_range_fn(worker_index, device):
        """This function will throw an OutOfRange error."""
        # As this will be only called when there is no data left, so calling
        # get_next() will trigger an OutOfRange error.
        data = self._iterators[worker_index].get_next(device)
        out_of_range_replicas.append(data)
        return data
  
      global_has_value, replicas = _get_next_as_optional(self, self._strategy)
      results = []
      for i, worker in enumerate(self._input_workers.worker_devices):
        with ops.device(worker):
          devices = self._input_workers.compute_devices_for_worker(i)
          for j, device in enumerate(devices):
            with ops.device(device):
              # pylint: disable=undefined-loop-variable
              # pylint: disable=cell-var-from-loop
              # It is fine for the lambda to capture variables from the loop as
              # the lambda is executed in the loop as well.
              result = control_flow_ops.cond(global_has_value,
                                             lambda: replicas[i][j],
                                             lambda: out_of_range_fn(i, device))
              # pylint: enable=cell-var-from-loop
              # pylint: enable=undefined-loop-variable
              results.append(result)
      replicas = results
  
      # Some dimensions in `replicas` will become unknown after we conditionally
      # return the real tensors or the dummy tensors. We fix the input shapes by
      # using the shapes from `out_of_range_replicas` because it is calling
      # get_next() inside.
      flattened_replicas = nest.flatten(replicas)
      for i, replica_data in enumerate(nest.flatten(out_of_range_replicas)):
        flattened_replicas[i].set_shape(replica_data.get_shape())
      replicas = nest.pack_sequence_as(replicas, flattened_replicas)
  
      return values.regroup(self._input_workers.device_map, replicas)
function_tokens: def get_next ( self , name = None ) : if not self . _enable_get_next_as_optional : replicas = [ ] for i , worker in enumerate ( self . _input_workers . worker_devices ) : if name is not None : d = tf_device . DeviceSpec . from_string ( worker ) new_name = "%s_%s_%d" % ( name , d . job , d . task ) else : new_name = None with ops . device ( worker ) : # Make `replicas` a flat list of values across all replicas. replicas . extend ( self . _iterators [ i ] . get_next_as_list_deprecated ( new_name ) ) return values . regroup ( self . _input_workers . device_map , replicas ) out_of_range_replicas = [ ] def out_of_range_fn ( worker_index , device ) : """This function will throw an OutOfRange error.""" # As this will be only called when there is no data left, so calling # get_next() will trigger an OutOfRange error. data = self . _iterators [ worker_index ] . get_next ( device ) out_of_range_replicas . append ( data ) return data global_has_value , replicas = _get_next_as_optional ( self , self . _strategy ) results = [ ] for i , worker in enumerate ( self . _input_workers . worker_devices ) : with ops . device ( worker ) : devices = self . _input_workers . compute_devices_for_worker ( i ) for j , device in enumerate ( devices ) : with ops . device ( device ) : # pylint: disable=undefined-loop-variable # pylint: disable=cell-var-from-loop # It is fine for the lambda to capture variables from the loop as # the lambda is executed in the loop as well. result = control_flow_ops . cond ( global_has_value , lambda : replicas [ i ] [ j ] , lambda : out_of_range_fn ( i , device ) ) # pylint: enable=cell-var-from-loop # pylint: enable=undefined-loop-variable results . append ( result ) replicas = results # Some dimensions in `replicas` will become unknown after we conditionally # return the real tensors or the dummy tensors. We fix the input shapes by # using the shapes from `out_of_range_replicas` because it is calling # get_next() inside. flattened_replicas = nest . flatten ( replicas ) for i , replica_data in enumerate ( nest . flatten ( out_of_range_replicas ) ) : flattened_replicas [ i ] . set_shape ( replica_data . get_shape ( ) ) replicas = nest . pack_sequence_as ( replicas , flattened_replicas ) return values . regroup ( self . _input_workers . device_map , replicas )